summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/csv.rb3
-rwxr-xr-xtest/csv/test_features.rb8
-rw-r--r--version.h2
4 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f04ab09f4c..1efe7e61ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Mar 31 00:57:39 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]
+
Mon Mar 31 00:48:12 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* test/ruby/envutil.rb (assert_no_memory_leak): increase default value
diff --git a/lib/csv.rb b/lib/csv.rb
index fe153153be..ce26221f37 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1504,8 +1504,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 698d92144d..5f8550e6ee 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 => "|")
diff --git a/version.h b/version.h
index 5ab5ff9cc7..46ea102ca2 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2014-03-31"
-#define RUBY_PATCHLEVEL 465
+#define RUBY_PATCHLEVEL 466
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 3