aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/csv.rb3
-rwxr-xr-xtest/csv/test_features.rb8
3 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 320767eca8..2ecf045954 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Mar 20 11:37:28 2014 James Edward Gray II <james@graysoftinc.com>
+
+ * 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]
+
Thu Mar 20 16:53:07 2014 Koichi Sasada <ko1@atdot.net>
* gc.c (objspace_malloc_increase): should not invoke
diff --git a/lib/csv.rb b/lib/csv.rb
index e5ecf5c9a8..2326792cd7 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1507,8 +1507,7 @@ class CSV
# 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)
diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb
index a83fff84d8..ad7e44d854 100755
--- a/test/csv/test_features.rb
+++ b/test/csv/test_features.rb
@@ -74,6 +74,14 @@ class TestCSV::Features < TestCSV
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 => "|")