8000 * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that · ruby/ruby@8662841 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8662841

Browse files
committed
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 73645bb commit 8662841

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Aug 30 06:23:40 2014 Aaron Patterson <aaron@tenderlovemaking.com>
2+
3+
* ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that
4+
look like integers but have a newline. Fixes GH #189
5+
* test/psych/test_string.rb: test for fix
6+
17
Sat Aug 30 06:10:39 2014 Aaron Patterson <aaron@tenderlovemaking.com>
28

39
* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash

ext/psych/lib/psych/scalar_scanner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def tokenize string
3737
case string
3838
# Check for a String type, being careful not to get caught by hash keys, hex values, and
3939
# special floats (e.g., -.inf).
40-
when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/
40+
when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
4141
if string.length > 5
4242
@string_cache[string] = true
4343
return string

test/psych/test_string.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def initialize
1515
end
1616
end
1717

18+
def test_string_with_newline
19+
assert_equal "1\n2", Psych.load("--- ! '1\n\n 2'\n")
20+
end
21+
1822
def test_no_doublequotes_with_special_characters
1923
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
2024
end

0 commit comments

Comments
 (0)
0