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

YAML::Store does not retrieve UTF8 values correctly in read-only mode #4770

Closed
duritong opened this issue Sep 1, 2017 · 4 comments
Closed

Comments

@duritong
Copy link
Contributor

duritong commented Sep 1, 2017

While investigating further problems on 9.1.7.0 related to #4767 I came accross a weird behavior of YAML::Store which does not print out correct unicode characters if the transaction is in readonly.

This is a small script that shows the problem

$ ruby --version
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 25.141-b16 on 1.8.0_141-b16 +jit [linux-x86_64]
$ cat pstore_test.rb 
require 'yaml/store'

puts 'PStore'
store = PStore.new('test.pstore')
store.transaction{ store['test'] = 'Tütü' }
print 'Correct: '
puts store.transaction{ store['test'] }
print 'Correct: '
puts store.transaction(true){ store['test'] }

puts 'YAML'
store = YAML::Store.new('test.yaml')
store.transaction{ store['test'] = 'Tütü' }
print 'Correct: '
puts store.transaction{ store['test'] }
print 'Incorrect: '
puts store.transaction(true){ store['test'] }
$ rm test.*
$ ruby pstore_test.rb 
PStore
Correct: Tütü
Correct: Tütü
YAML
Correct: Tütü
Incorrect: Tütü
duritong added a commit to duritong/jruby that referenced this issue Sep 1, 2017
@duritong
Copy link
Contributor Author

duritong commented Sep 1, 2017

I added a testcase in #4771 that shows the problem and hopefully will avoid future regressions.

@enebo
Copy link
Member

enebo commented Sep 5, 2017

Reduced this a bit:

jruby -ryaml -e 'p YAML.load(File.open("test.yaml", {encoding: Encoding::ASCII_8BIT}))["test"]'

If I change this to UTF-8 it works so I am guessing YAML as a library might be capable of negotiating ASCII_8BIT to valid UTF-8 and our version doesn't?

@enebo
Copy link
Member

enebo commented Sep 5, 2017

I submitted a PR for this to psych but I will work around it locally in yaml/store until that new version is out so you can see this fixed in 9.1.13.0.

enebo added a commit that referenced this issue Sep 5, 2017
…ead-only mode.

This is just a work around until Psych is updated with a proper fix.  I opened
#4779 to make sure I delete this fix later.
@enebo enebo closed this as completed in e5b800e Sep 5, 2017
@enebo enebo added this to the JRuby 9.1.13.0 milestone Sep 5, 2017
@headius
Copy link
Member

headius commented Sep 7, 2017

Link to #4784.

enebo added a commit that referenced this issue Jan 10, 2018
…eadonly-transaction

an example test case for #4770 that shows how unicode readings fails …
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

3 participants