Uwe Kubosch created JRUBY-6269:
----------------------------------

             Summary: JRuby --1.9 cannot load YAML output from JRuby --1.8
                 Key: JRUBY-6269
                 URL: https://jira.codehaus.org/browse/JRUBY-6269
             Project: JRuby
          Issue Type: Bug
          Components: Standard Library
    Affects Versions: JRuby 1.6.5
            Reporter: Uwe Kubosch
            Assignee: Thomas E Enebo
             Fix For: JRuby 1.6.6, JRuby 1.7


I open this issue mostly for discussion since I suspect that there is not bug, 
but it represents a real world problem.

If you use JRuby in 1.8 mode and dump a string containing a TAB character, you 
get something like this:

{noformat}
macbeth:~ uwe$ jruby --1.8 -ryaml -S jirb
>> YAML.dump("36L\tDIESEL")
=> "--- 36L\tDIESEL\n"
>> YAML.load "--- 36L\tDIESEL\n"
=> "36L\tDIESEL"
>> 
{noformat}

Notice the TAB character is embedded verbatim in the YAML stream.  No quoting, 
no escaping.  YAML.load works fine with this stream.

Now the same for --1.9 mode:

{noformat}
macbeth:~ uwe$ jruby --1.9 -ryaml -S jirb
irb(main):001:0> YAML.dump("36L\tDIESEL")
=> "--- ! \"36L\\tDIESEL\"\n...\n"
irb(main):002:0> YAML.load "--- ! \"36L\\tDIESEL\"\n...\n"
=> "36L\tDIESEL"
{noformat}

Notice that now the TAB character is both quoted and escaped.  YAML.load work 
fine on this stream as well.

But what happens if we try to parse the stream generated by JRuby 1.8 with 
JRuby 1.9?

{noformat}
macbeth:~ uwe$ jruby --1.9 -ryaml -S jirb
irb(main):001:0> YAML.load "--- 36L\tDIESEL\n"
ArgumentError: syntax error in "<reader>", line 1, column 8:
    --- 36L     DIESEL
           ^
        from org/jruby/ext/psych/PsychParser.java:273:in `parse'
        from 
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/1.9/psych.rb:148:in 
`parse_stream'
        from 
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/1.9/psych.rb:119:in 
`parse'
        from 
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/1.9/psych.rb:106:in 
`load'
        from (irb):3:in `evaluate'
        from org/jruby/RubyKernel.java:1093:in `eval'
        from org/jruby/RubyKernel.java:1420:in `loop'
        from org/jruby/RubyKernel.java:1206:in `catch'
        from org/jruby/RubyKernel.java:1206:in `catch'
        from /Library/Frameworks/JRuby.framework/Versions/1.6.5/bin/jirb:13:in 
`(root)'
{noformat}

It blows up.  We are seeing this in production, so we need a solution to this 
problem.  On the receiver (consumer) side of the exchange, we use event based 
parsing with Psych::Parser and Psych::Handler so, as far as I know, reverting 
to syck is not an option.

Any help on this is greatly appreciated, and time is of the essence.  We are 
currently just avoiding the problem by disallowing offending input, but we need 
a permanent solution for this:

How can we safely generate YAML with JRuby 1.8 and parse it with JRuby 1.9 
using event based parsing?

P.S.  On the consumer side, we are actually running JRuby in 1.8 mode, but we 
pull in Psych explicitly.  I mention this only to open up more possibilities 
for a solution.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to