vagrant/test/unit/vagrant
Sam Phippen eeb750cd33 Catch encoding problems with sources provided to Vagrant::Config::Loader#set
Here we implement a naive solution to #5605 which catches the case that
a provided source contains an object which cannot be inspected, because
an object contained within in has an #inspect string that returns a
string that is incompatible with the encoding in
`Encoding.default_external` or a string which cannot be downcast to
7-bit ascii.

The Ruby VM implementation of "#inspect" implements this checking on
these lines of code: http://git.io/vZYNS. A Ruby level override of
this method does not cause this problem. For example:

```ruby
class Foo
  def inspect
    "😍".encode("UTF-16LE")
  end
```

will not cause the problem, because that's a Ruby implementation and the
VM's checks don't occur.

However, if we have an Object which **does** use the VM implementation
of inspect, that contains an object that has an inspect string which
returns non-ascii, we encounter the bug. For example:

```ruby
class Bar
  def inspect
    "😍".encode("UTF-16LE")
  end
end

class Foo
  def initialize
     @bar = Bar.new
  end
end

Foo.new.inspect
```

Will cause the issue.

The solution this patch provides basically catches the encoding error
and inserts a string which attempts to help the user work out which
object was provided without blowing up. Most likely, this was caused
by a user having a weird encoding coming out of one of the sources
passed in, but without a full repro case, it's not clear whether a patch
should be applied to a different object in the system.

Closes #5605.
2015-09-08 17:30:50 +01:00
..
action Merge branch 'filter_synced_folders' of https://github.com/maxlinc/vagrant into maxlinc-filter_synced_folders 2015-07-09 15:05:52 -06:00
config Catch encoding problems with sources provided to Vagrant::Config::Loader#set 2015-09-08 17:30:50 +01:00
plugin core: fix crash for missing options [GH-5550] 2015-07-06 10:36:41 -06:00
util core: test for URI escaping 2015-07-06 16:26:06 -06:00
batch_action_test.rb Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
box_collection_test.rb core: box names with colons work on Windows [GH-4100] 2014-08-08 14:47:17 -07:00
box_metadata_test.rb core: better error when adding box with malformed version [GH-3332] 2014-04-01 22:48:52 -07:00
box_test.rb core: Box#in_use? as an API 2014-04-25 02:02:49 -07:00
capability_host_test.rb core: pass extra args to detect? when detecting capability host 2014-01-07 16:26:58 -08:00
cli_test.rb Convert specs to RSpec 2.14.8 syntax with Transpec 2014-03-14 12:02:07 -03:00
config_test.rb Convert specs to RSpec 2.14.8 syntax with Transpec 2014-03-14 12:02:07 -03:00
environment_test.rb Validate pushes in the global config 2015-01-07 15:51:20 -05:00
errors_test.rb Convert specs to RSpec 2.14.8 syntax with Transpec 2014-03-14 12:02:07 -03:00
guest_test.rb Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
host_test.rb Convert specs to RSpec 2.14.8 syntax with Transpec 2014-03-14 12:02:07 -03:00
machine_index_test.rb core: MachineIndex valid test is better 2014-05-05 21:50:51 -07:00
machine_state_test.rb Convert specs to RSpec 2.14.8 syntax with Transpec 2014-03-14 12:02:07 -03:00
machine_test.rb core: save the UID that created a machine 2015-07-06 18:04:16 -06:00
registry_test.rb Do not use Enumerable in Registry 2014-12-08 11:35:10 -08:00
shared_helpers_test.rb provisioners/chef: put global lock around knife exec 2014-08-06 10:24:05 -07:00
ui_test.rb Add UI::Interface#color? 2015-06-01 11:49:09 -04:00
vagrantfile_test.rb core: only delete state if not created on initialize only 2014-11-10 16:29:19 -08:00