Removing escapeSql per LANG-493
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@786942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1645f246d3
commit
bc1104da49
|
@ -665,32 +665,6 @@ public static String unescapeXml(String str) {
|
||||||
return Entities.XML.unescape(str);
|
return Entities.XML.unescape(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>Escapes the characters in a <code>String</code> to be suitable to pass to
|
|
||||||
* an SQL query.</p>
|
|
||||||
*
|
|
||||||
* <p>For example,
|
|
||||||
* <pre>statement.executeQuery("SELECT * FROM MOVIES WHERE TITLE='" +
|
|
||||||
* StringEscapeUtils.escapeSql("McHale's Navy") +
|
|
||||||
* "'");</pre>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* <p>At present, this method only turns single-quotes into doubled single-quotes
|
|
||||||
* (<code>"McHale's Navy"</code> => <code>"McHale''s Navy"</code>). It does not
|
|
||||||
* handle the cases of percent (%) or underscore (_) for use in LIKE clauses.</p>
|
|
||||||
*
|
|
||||||
* 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, <code>null</code> if null string input
|
|
||||||
*/
|
|
||||||
public static String escapeSql(String str) {
|
|
||||||
if (str == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return StringUtils.replace(str, "'", "''");
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -324,17 +324,6 @@ public void testEscapeXml() throws Exception {
|
||||||
assertEquals("XML was unescaped incorrectly", "<abc>", sw.toString() );
|
assertEquals("XML was unescaped incorrectly", "<abc>", 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
|
// Tests issue #38569
|
||||||
// http://issues.apache.org/bugzilla/show_bug.cgi?id=38569
|
// http://issues.apache.org/bugzilla/show_bug.cgi?id=38569
|
||||||
public void testStandaloneAmphersand() {
|
public void testStandaloneAmphersand() {
|
||||||
|
|
Loading…
Reference in New Issue