mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3e20c50d50
commit
3fb752a921
3 changed files with 17 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 => "|")
|
||||
|
|
Loading…
Reference in a new issue