ruby-changes:33875
From: nagachika <ko1@a...>
Date: Fri, 16 May 2014 00:28:26 +0900 (JST)
Subject: [ruby-changes:33875] nagachika:r45956 (ruby_2_1): merge revision(s) r45374: [Backport #8405]
nagachika 2014-05-16 00:28:16 +0900 (Fri, 16 May 2014) New Revision: 45956 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45956 Log: merge revision(s) r45374: [Backport #8405] * lib/csv.rb: Fixed a broken regular expression that was causing CSV to miss escaping some special meaning characters when used in parsing. Reported by David Unric [ruby-core:54986] [Bug #8405] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/lib/csv.rb branches/ruby_2_1/test/csv/test_features.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 45955) +++ ruby_2_1/ChangeLog (revision 45956) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Fri May 16 00:27:02 2014 James Edward Gray II <james@g...> + + * lib/csv.rb: Fixed a broken regular expression that was causing + CSV to miss escaping some special meaning characters when used + in parsing. + Reported by David Unric + [ruby-core:54986] [Bug #8405] + Fri May 16 00:14:25 2014 Kohei Suzuki <eagletmt@g...> * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0 Index: ruby_2_1/lib/csv.rb =================================================================== --- ruby_2_1/lib/csv.rb (revision 45955) +++ ruby_2_1/lib/csv.rb (revision 45956) @@ -1507,8 +1507,7 @@ class CSV https://github.com/ruby/ruby/blob/trunk/ruby_2_1/lib/csv.rb#L1507 # if we can transcode the needed characters # @re_esc = "\\".encode(@encoding) rescue "" - @re_chars = /#{%"[-][\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ - # @re_chars = /#{%"[-][\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding, fallback: proc{""})}/ + @re_chars = /#{%"[-\\]\\[\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ init_separators(options) init_parsers(options) Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 45955) +++ ruby_2_1/version.h (revision 45956) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-16" -#define RUBY_PATCHLEVEL 101 +#define RUBY_PATCHLEVEL 102 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 Index: ruby_2_1/test/csv/test_features.rb =================================================================== --- ruby_2_1/test/csv/test_features.rb (revision 45955) +++ ruby_2_1/test/csv/test_features.rb (revision 45956) @@ -74,6 +74,14 @@ class TestCSV::Features < TestCSV https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/csv/test_features.rb#L74 end end + def test_bug_8405 + TEST_CASES.each do |test_case| + assert_equal( test_case.last.map { |t| t.tr('"', "|") unless t.nil? }, + CSV.parse_line( test_case.first.tr('"', "|"), + quote_char: "|" ) ) + end + end + def test_csv_char_readers %w[col_sep row_sep quote_char].each do |reader| csv = CSV.new("abc,def", reader.to_sym => "|") Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45374 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/