psych icon indicating copy to clipboard operation
psych copied to clipboard

Different behavior when parsing tabs in between JRuby and MRI Ruby versions

Open Gawyn opened this issue 5 years ago • 1 comments

In certain cases, MRI Ruby Psych and JRuby Psych will return different results for the same string, even if both of them are in the same version. For example, this happens when parsing in MRI Ruby:

Psych.load("location:\tCalifornia")
irb(main):002:0> Psych.load("location:\tCalifornia")
=> {"location"=>"California"}

Meanwhile, JRuby throws an exception:

irb(main):008:0> Psych.load("location:\tCalifornia")
Traceback (most recent call last):
       10: from /Users/cplanas/.rbenv/versions/jruby-9.2.9.0/bin/irb:13:in `<main>'
        9: from org/jruby/RubyKernel.java:1193:in `catch'
        8: from org/jruby/RubyKernel.java:1193:in `catch'
        7: from org/jruby/RubyKernel.java:1446:in `loop'
        6: from org/jruby/RubyKernel.java:1052:in `eval'
        5: from (irb):8:in `evaluate'
        4: from /Users/cplanas/.rbenv/versions/jruby-9.2.9.0/lib/ruby/gems/shared/gems/psych-3.2.0-java/lib/psych.rb:277:in `load'
        3: from /Users/cplanas/.rbenv/versions/jruby-9.2.9.0/lib/ruby/gems/shared/gems/psych-3.2.0-java/lib/psych.rb:388:in `parse'
        2: from /Users/cplanas/.rbenv/versions/jruby-9.2.9.0/lib/ruby/gems/shared/gems/psych-3.2.0-java/lib/psych.rb:454:in `parse_stream'
        1: from org/jruby/ext/psych/PsychParser.java:246:in `parse'
Psych::SyntaxError ((<unknown>): found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation) while scanning for the next token at line 1 column 10)

I tested this in version3.2.0.

Gawyn avatar Sep 10 '20 00:09 Gawyn

@headius Is this limitation of SnakeYAML?

hsbt avatar Apr 19 '24 09:04 hsbt