Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serializing HighLine::String to yaml produces strange results #69

Closed
viking opened this issue Mar 7, 2013 · 6 comments
Closed

serializing HighLine::String to yaml produces strange results #69

viking opened this issue Mar 7, 2013 · 6 comments

Comments

@viking
Copy link

viking commented Mar 7, 2013

Consider:

require 'highline'
require 'yaml'

hl = HighLine.new
x = hl.ask("foo: ")
puts x.to_yaml

Output:

foo: bar
--- !ruby/string:HighLine::String |-
  YmFy

I'm using ruby 2.0.0-p0.

@JEG2
Copy link
Owner

JEG2 commented Mar 7, 2013

Strange results in that you just want a normal String? I'm just making sure I understand.

@viking
Copy link
Author

viking commented Mar 7, 2013

Yes, that, and the serialization does not appear to be reversible (which is the bigger problem):

require 'highline'
require 'yaml'

hl = HighLine.new
x = hl.ask("foo: ")
puts x.to_yaml
p YAML.load(x.to_yaml)

Output:

foo: bar
--- !ruby/string:HighLine::String |-
  YmFy
"YmFy"

@JEG2
Copy link
Owner

JEG2 commented Mar 7, 2013

Yeah, we do need to fix this.

@mocoso
Copy link

mocoso commented Apr 26, 2013

This is a problem with YAML/Psych in ruby 2.0.0-p0 which does not handle subclasses of String correctly e.g.

require 'yaml'

class X < String
end

x =X.new('foo')
p YAML.load(x.to_yaml)

Output

"Zm9v"

therubymug pushed a commit to therubymug/hitch that referenced this issue Nov 19, 2013
- Due to an issue in the highline gem, serializing HighLine::Strings
  produce weird results. This is a "fix" for that greater issue.
- JEG2/highline#69

closes #18
maltoe pushed a commit to projectivetech/mgit that referenced this issue Dec 4, 2013
abinoam added a commit to abinoam/highline that referenced this issue Feb 4, 2015
This was a YAML related bug (not HighLine one).
Writing this test to protect against regressions.
@abinoam
Copy link
Collaborator

abinoam commented Feb 4, 2015

I couldn't reproduce the issue anymore. I think it was fixed in YAML. Added a test on 1c6a8fa to serve as guard against any future regression.

@JEG2 JEG2 closed this as completed in 1c6a8fa Feb 4, 2015
JEG2 added a commit that referenced this issue Feb 4, 2015
Add test for Yaml serialization of HighLine::String - closes #69
@JEG2
Copy link
Owner

JEG2 commented Feb 4, 2015

Perfect.

abinoam added a commit to abinoam/highline that referenced this issue Feb 19, 2015
This was a YAML related bug (not HighLine one).
Writing this test to protect against regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants