Bug #4342: YAML raises an exception while parsing certain regular expressions
http://redmine.ruby-lang.org/issues/show/4342

Author: Andrew Grimm
Status: Open, Priority: Normal
ruby -v: ruby 1.9.3dev (2011-01-29 trunk 30720) [x86_64-darwin10.4.0] 

Roundtripping does not work for the regular expresion //n , and this appears to be distinct from Backport87 bug 1639.

irb -d
ruby-head :001 > require "yaml"
Exception `NameError' at /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck/tag.rb:81 - method `yaml_as' not defined in Module
 => true 
ruby-head :002 > Regexp.new('',0,'n')
 => //n 
ruby-head :003 > YAML.dump(Regexp.new('',0,'n'))
 => "--- !ruby/regexp //n\n" 
ruby-head :004 > YAML.load(YAML.dump(Regexp.new('',0,'n')))
Exception `Syck::TypeError' at /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck/rubytypes.rb:283 - Invalid Regular expression: "//n"
Exception `Syck::TypeError' at /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/irb/workspace.rb:80 - Invalid Regular expression: "//n"
Syck::TypeError: Invalid Regular expression: "//n"
	from /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck/rubytypes.rb:283:in `yaml_new'
	from /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck.rb:135:in `transfer'
	from /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck.rb:135:in `node_import'
	from /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck.rb:135:in `load'
	from /Users/agrimm/.rvm/rubies/ruby-head/lib/ruby/1.9.1/syck.rb:135:in `load'
	from (irb):4
	from /Users/agrimm/.rvm/rubies/ruby-head/bin/irb:16:in `<main>'
ruby-head :005 > # The following works, indicating it's distinct from backport87 bug 1639
ruby-head :006 >   YAML.load(YAML.dump(Regexp.new('',0,'u')))
(irb):6: warning: encoding option is ignored - u
 => //


----------------------------------------
http://redmine.ruby-lang.org