From: jeg2@... Date: 2014-03-20T14:38:29+00:00 Subject: [ruby-core:61612] [ruby-trunk - Bug #8405] [Closed] CSV module - improper regexp for escaping special characters Issue #8405 has been updated by James Gray. Status changed from Assigned to Closed % Done changed from 0 to 100 Applied in changeset r45374. ---------- * 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] ---------------------------------------- Bug #8405: CSV module - improper regexp for escaping special characters https://bugs.ruby-lang.org/issues/8405#change-45883 * Author: David Unric * Status: Closed * Priority: Normal * Assignee: James Gray * Category: lib * Target version: current: 2.2.0 * ruby -v: 2.0.0p0 * Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN ---------------------------------------- =begin There seems to be bug in csv.rb module. If you would like to use some special characters like (({|})) as a quote_char (passed as a parameter to CSV methods like read), program terminates with (({CSV::MalformedCSVError: Missing or stray quote in line xxx})) error message even if the input .csv file is correct. Bellow is the assignment of the Regexp used for escaping special symbols used in regular expressions: 1587: @re_chars = /#{%"[-][\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ The issue is with the leading (({[-]})) which I find completely wrong and causes miss of all matches it was intended to. The hyphen char "(({-}))" has to be escaped only inside brackets (({[]})) and only if it does not immediately follow the left bracket. The quick fix for the above issue may look like 1587: @re_chars = /#{%"(?