summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-02-06 10:02:04 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2015-02-06 10:02:04 +0200
commit6a191f45986a0ace06b743145364e6e66da46b9b (patch)
tree482897d0213b19c088d8b6156fde6a6c0271ed4e
parent8cacb47218ff693cbcf69b485b49e6dbe0927a66 (diff)
downloadpsych-6a191f45986a0ace06b743145364e6e66da46b9b.tar.gz
* ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular
expressions with newlines. tenderlove/psych#222 * test/psych/test_yaml.rb: test for change. fixes #222
-rw-r--r--CHANGELOG.rdoc7
-rw-r--r--lib/psych/visitors/to_ruby.rb4
-rw-r--r--test/psych/test_yaml.rb4
3 files changed, 13 insertions, 2 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 0172b4b..cc4ba23 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,3 +1,10 @@
+Fri Feb 6 16:58:31 2015 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular
+ expressions with newlines. tenderlove/psych#222
+
+ * test/psych/test_yaml.rb: test for change.
+
Thu Jan 29 02:34:27 2015 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/to_ruby.rb: fix parsing hashes with
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index 5bd33b4..b68abb6 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -32,7 +32,7 @@ module Psych
return result if @domain_types.empty? || !target.tag
key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
- key = "tag:#{key}" unless key =~ /^(tag:|x-private)/
+ key = "tag:#{key}" unless key =~ /^(?:tag:|x-private)/
if @domain_types.key? key
value, block = @domain_types[key]
@@ -89,7 +89,7 @@ module Psych
Float(@ss.tokenize(o.value))
when "!ruby/regexp"
klass = class_loader.regexp
- o.value =~ /^\/(.*)\/([mixn]*)$/
+ o.value =~ /^\/(.*)\/([mixn]*)$/m
source = $1
options = 0
lang = nil
diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb
index cd3e8ee..e628175 100644
--- a/test/psych/test_yaml.rb
+++ b/test/psych/test_yaml.rb
@@ -27,6 +27,10 @@ class Psych_Unit_Tests < Psych::TestCase
assert_match "2010-10-10 00:00:00.000000000 Z", yaml
end
+ def test_multiline_regexp
+ assert_cycle(Regexp.new("foo\nbar"))
+ end
+
# [ruby-core:34969]
def test_regexp_with_n
assert_cycle(Regexp.new('',0,'n'))