vagrant/lib/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 Use the same ssh args for ssh with a command as ssh exec 2015-07-10 13:55:00 -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 Use a properly-formatted custom User-Agent 2015-07-20 23:33:31 -04:00
action.rb providers/hyperv: suspend/resume 2014-02-27 08:13:11 -08:00
batch_action.rb Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
box.rb box/package: Take only files while packaging the new box 2015-04-30 16:08:18 +03:00
box_collection.rb Style fixes 2015-06-02 17:18:50 -04:00
box_metadata.rb core: better error when adding box with malformed version [GH-3332] 2014-04-01 22:48:52 -07:00
bundler.rb Revert "Merge pull request #4861 from obfusk/fix-tmpdir-delete" 2014-12-02 12:32:31 -05:00
capability_host.rb Use .key? instead of .has_key? 2015-01-05 18:29:01 -05:00
cli.rb Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
config.rb core: configure version can be an int [GH-2689] 2013-12-19 08:03:15 -08:00
environment.rb Create data dir only after the machine passes all checks 2015-02-12 14:32:16 +02:00
errors.rb providers/virtualbox: error if uid mismatch 2015-07-06 18:13:59 -06:00
guest.rb core: more user-friendly errors for caps on guests 2014-01-09 10:24:25 -08:00
host.rb core: pass environment into all host caps 2014-01-07 20:34:33 -08:00
machine.rb Merge pull request #5514 from MiLk/fixes/several-boxes-same-name 2015-07-09 15:00:03 -06:00
machine_index.rb core: MachineIndex valid test is better 2014-05-05 21:50:51 -07:00
machine_state.rb core: if state ID is NOT_CREATED_ID, destroy machine state 2014-05-05 21:44:34 -07:00
plugin.rb commands/plugin: list uses PluginManager 2014-01-05 08:42:34 -08:00
pre-rubygems.rb Very quiet mode for development 2014-04-21 13:56:39 -07:00
registry.rb Use .key? instead of .has_key? 2015-01-05 18:29:01 -05:00
shared_helpers.rb core: plugin management requires bundler 2015-07-10 13:37:33 +02:00
ui.rb Add UI::Interface#color? 2015-06-01 11:49:09 -04:00
util.rb Add Env.with_clean_env for resetting the Ruby and Rubygems environment 2014-11-10 12:00:23 -05:00
vagrantfile.rb Create data dir only after the machine passes all checks 2015-02-12 14:32:16 +02:00
version.rb Add new version.txt used to generate installers 2014-02-02 15:33:12 +01:00