summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb2
-rw-r--r--test/psych/test_string.rb4
3 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 29aa26f648f..539f5d84f40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Aug 30 06:23:40 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that
+ look like integers but have a newline. Fixes GH #189
+ * test/psych/test_string.rb: test for fix
+
Sat Aug 30 06:10:39 2014 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index 3fc9edd25dc..93007902a76 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -37,7 +37,7 @@ module Psych
case string
# Check for a String type, being careful not to get caught by hash keys, hex values, and
# special floats (e.g., -.inf).
- when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/
+ when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
if string.length > 5
@string_cache[string] = true
return string
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index f1f061b305f..1ce16fdf3ec 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -15,6 +15,10 @@ module Psych
end
end
+ def test_string_with_newline
+ assert_equal "1\n2", Psych.load("--- ! '1\n\n 2'\n")
+ end
+
def test_no_doublequotes_with_special_characters
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
end