Skip to content

Commit

Permalink
New version 2.4.3: Escape CRLF in ODBC driver code for Access/SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
jmozmoz committed Sep 28, 2011
1 parent d142140 commit 2f41e40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion activerecord-odbc-adapter.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{activerecord-odbc-adapter}
s.version = "2.4.2"
s.version = "2.4.3"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Carl Blakeley", "Sytse Sijbrandij", "James Herdman", "Andrew Rollins"]
Expand Down
3 changes: 2 additions & 1 deletion lib/active_record/vendor/odbcext_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def remove_null_sequence_value_from_sql(sql, sequence_column)
@logger.unknown("sql=[#{sql}|#{sequence_column}]") if @trace
idQuoteChar = @dsInfo.info[ODBC::SQL_IDENTIFIER_QUOTE_CHAR]
valQuoteChar = "'"
sql.gsub!(/\r\n/, '\r\n') # escape CRLF
sql =~ /(.*)\((.*)\) *VALUES *\((.*)\)(.*)/
start = $1
columns = FasterCSV.parse($2, :quote_char=>idQuoteChar, :col_sep=>', ').flatten
Expand All @@ -164,7 +165,7 @@ def remove_null_sequence_value_from_sql(sql, sequence_column)
values[i].gsub!(/#{valQuoteChar}/, "#{valQuoteChar}#{valQuoteChar}") # requote quote char
values[i] = Regexp.escape(values[i]) # now escape it to use it in the regexp below
rest_str =~ /^ *(#{valQuoteChar}*#{values[i]}[^,]*),* *.*/
new_values << $1
new_values << $1.gsub('\r\n', "\r\n") # insert CRLF again
@logger.unknown("columns[i]=#{columns[i]}") if @trace
@logger.unknown("$1=#{$1}") if @trace
end
Expand Down
3 changes: 2 additions & 1 deletion lib/active_record/vendor/odbcext_microsoftsqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def remove_null_sequence_value_from_sql(sql, sequence_column)
@logger.unknown("sql=[#{sql}|#{sequence_column}]") if @trace
idQuoteChar = @dsInfo.info[ODBC::SQL_IDENTIFIER_QUOTE_CHAR]
valQuoteChar = "'"
sql.gsub!(/\r\n/, '\r\n') # escape CRLF
sql =~ /(.*)\((.*)\) *VALUES *\((.*)\)(.*)/
start = $1
columns = FasterCSV.parse($2, :quote_char=>idQuoteChar, :col_sep=>', ').flatten
Expand All @@ -263,7 +264,7 @@ def remove_null_sequence_value_from_sql(sql, sequence_column)
values[i].gsub!(/#{valQuoteChar}/, "#{valQuoteChar}#{valQuoteChar}") # requote quote char
values[i] = Regexp.escape(values[i]) # now escape it to use it in the regexp below
rest_str =~ /^ *(#{valQuoteChar}*#{values[i]}[^,]*),* *.*/
new_values << $1
new_values << $1.gsub('\r\n', "\r\n") # insert CRLF again
@logger.unknown("columns[i]=#{columns[i]}") if @trace
@logger.unknown("$1=#{$1}") if @trace
end
Expand Down

0 comments on commit 2f41e40

Please sign in to comment.