[前][次][番号順一覧][スレッド一覧]

ruby-changes:35236

From: tenderlove <ko1@a...>
Date: Sat, 30 Aug 2014 06:24:49 +0900 (JST)
Subject: [ruby-changes:35236] tenderlove:r47318 (trunk): * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that

tenderlove	2014-08-30 06:24:33 +0900 (Sat, 30 Aug 2014)

  New Revision: 47318

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47318

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/scalar_scanner.rb
    trunk/test/psych/test_string.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47317)
+++ ChangeLog	(revision 47318)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug 30 06:23:40 2014  Aaron Patterson <aaron@t...>
+
+	* 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@t...>
 
 	* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
Index: ext/psych/lib/psych/scalar_scanner.rb
===================================================================
--- ext/psych/lib/psych/scalar_scanner.rb	(revision 47317)
+++ ext/psych/lib/psych/scalar_scanner.rb	(revision 47318)
@@ -37,7 +37,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/scalar_scanner.rb#L37
       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
Index: test/psych/test_string.rb
===================================================================
--- test/psych/test_string.rb	(revision 47317)
+++ test/psych/test_string.rb	(revision 47318)
@@ -15,6 +15,10 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_string.rb#L15
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]