Skip to content

Syck does not like Noémie. aka: Issues with UTF8 strings interpreted as Boolean values #22

@Bertg

Description

@Bertg

TLDR:

  • It seems certain UTF8 strings will be parsed into Boolean values.
  • It's not clear (by the tests or other examples) if this is intended
  • It's very surprising
  • Have no idea how to fix it

Bertg@acf9778#diff-4037826ea7c5075dd50bbcd81e29d17fR36

Longer story:

So, I was tracing down an issue in our test suite, where the faker gem was generating a false value for something that should be a string.

After a lot of digging I found that the Translation hash it loaded (using I18n), actually contained a false value. However, the YAML file does not.

This lead me to this awesome orb session:

2.3.1 :001 > $LOADED_FEATURES.grep(/YAML/).first
 => nil
2.3.1 :002 > require 'yaml'
 => true
2.3.1 :003 > $LOADED_FEATURES.grep(/YAML/).first
 => nil
2.3.1 :004 > YAML.load("Mélissa")
 => "Mélissa"
2.3.1 :005 > YAML.load("Noémie")
 => "Noémie"
2.3.1 :006 > require 'syck'
 => true
2.3.1 :007 > $LOADED_FEATURES.grep(/syck/).first
 => "/Users/bertg/.rvm/gems/ruby-2.3.1/gems/syck-1.3.0/lib/syck.bundle"
2.3.1 :008 > YAML.load("Mélissa")
 => "Mélissa"
2.3.1 :009 > YAML.load("Noémie")
 => false

And that's not all

2.3.1 :010 > YAML.load("--- 'Noémie'")
 => "Noémie"
2.3.1 :011 > YAML.load("--- ['Noémie']")
 => ["Noémie"]
2.3.1 :012 > YAML.load("--- [Noémie]")
 => [false]

So, let's see where the fail is!

2.3.1 :013 > YAML.load("Noé")
 => false
2.3.1 :014 > YAML.load("No")
 => false
2.3.1 :016 > YAML.load("Nom")
 => "Nom"
2.3.1 :017 > YAML.load("Noå")
 => false
2.3.1 :018 > YAML.load("Yeså")
 => true

So basically it seams a non ASCII character following a Boolean like value, will interpret that value as boolean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions