lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r908357 - in /lucene/solr/trunk/contrib/dataimporthandler: CHANGES.txt src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
Date Wed, 10 Feb 2010 05:38:57 GMT
Author: noble
Date: Wed Feb 10 05:38:56 2010
New Revision: 908357

URL: http://svn.apache.org/viewvc?rev=908357&view=rev
Log:
SOLR-1767: dataimporter.functions.escapeSql() does not escape backslash character

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java
    lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt?rev=908357&r1=908356&r2=908357&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt Wed Feb 10 05:38:56 2010
@@ -61,6 +61,8 @@
 
 * SOLR-1766: DIH with threads enabled doesn't respond to the abort command (Michael Henson
via noble)
 
+* SOLR-1767: dataimporter.functions.escapeSql() does not escape backslash character (Sean
Timm via noble) 
+
 Other Changes
 ----------------------
 

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java?rev=908357&r1=908356&r2=908357&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EvaluatorBag.java
Wed Feb 10 05:38:56 2010
@@ -72,7 +72,10 @@
           throw new DataImportHandlerException(SEVERE, "'escapeSql' must have at least one
parameter ");
         }
         String s = l.get(0).toString();
-        return s.replaceAll("'", "''").replaceAll("\"", "\"\"");
+        // escape single quote with two single quotes, double quote
+        // with two doule quotes, and backslash with double backslash.
+        // See:  http://dev.mysql.com/doc/refman/4.1/en/mysql-real-escape-string.html
+        return s.replaceAll("'", "''").replaceAll("\"", "\"\"").replaceAll("\\\\", "\\\\\\\\");
       }
     };
   }

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java?rev=908357&r1=908356&r2=908357&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
Wed Feb 10 05:38:56 2010
@@ -49,6 +49,7 @@
     sqlTests = new HashMap<String, String>();
 
     sqlTests.put("foo\"", "foo\"\"");
+    sqlTests.put("foo\\", "foo\\\\");
     sqlTests.put("foo'", "foo''");
     sqlTests.put("foo''", "foo''''");
     sqlTests.put("'foo\"", "''foo\"\"");



Mime
View raw message