diff --git a/src/java/org/apache/commons/lang/StringEscapeUtils.java b/src/java/org/apache/commons/lang/StringEscapeUtils.java index 148cd0166..92d613f67 100644 --- a/src/java/org/apache/commons/lang/StringEscapeUtils.java +++ b/src/java/org/apache/commons/lang/StringEscapeUtils.java @@ -665,32 +665,6 @@ public static String unescapeXml(String str) { return Entities.XML.unescape(str); } - //----------------------------------------------------------------------- - /** - *

Escapes the characters in a String to be suitable to pass to - * an SQL query.

- * - *

For example, - *

statement.executeQuery("SELECT * FROM MOVIES WHERE TITLE='" + 
-     *   StringEscapeUtils.escapeSql("McHale's Navy") + 
-     *   "'");
- *

- * - *

At present, this method only turns single-quotes into doubled single-quotes - * ("McHale's Navy" => "McHale''s Navy"). It does not - * handle the cases of percent (%) or underscore (_) for use in LIKE clauses.

- * - * see http://www.jguru.com/faq/view.jsp?EID=8881 - * @param str the string to escape, may be null - * @return a new String, escaped for SQL, null if null string input - */ - public static String escapeSql(String str) { - if (str == null) { - return null; - } - return StringUtils.replace(str, "'", "''"); - } - //----------------------------------------------------------------------- /** diff --git a/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java b/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java index 18e6233f4..8562a32e6 100644 --- a/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java +++ b/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java @@ -324,17 +324,6 @@ public void testEscapeXml() throws Exception { assertEquals("XML was unescaped incorrectly", "", sw.toString() ); } - // SQL - // see http://www.jguru.com/faq/view.jsp?EID=8881 - //-------------------- - - public void testEscapeSql() throws Exception - { - assertEquals("don''t stop", StringEscapeUtils.escapeSql("don't stop")); - assertEquals("", StringEscapeUtils.escapeSql("")); - assertEquals(null, StringEscapeUtils.escapeSql(null)); - } - // Tests issue #38569 // http://issues.apache.org/bugzilla/show_bug.cgi?id=38569 public void testStandaloneAmphersand() {