Fixing issue #38569
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@394875 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4143a12a0e
commit
2330a3343c
|
@ -820,6 +820,12 @@ class Entities {
|
|||
buf.append(ch);
|
||||
continue;
|
||||
}
|
||||
int amph = str.indexOf('&', i + 1);
|
||||
if( amph != -1 && amph < semi ) {
|
||||
// Then the text looks like &...&...;
|
||||
buf.append(ch);
|
||||
continue;
|
||||
}
|
||||
String entityName = str.substring(i + 1, semi);
|
||||
int entityValue;
|
||||
if (entityName.length() == 0) {
|
||||
|
@ -883,6 +889,12 @@ class Entities {
|
|||
writer.write(c);
|
||||
continue;
|
||||
}
|
||||
int amphersandIdx = string.indexOf('&', i + 1);
|
||||
if( amphersandIdx != -1 && amphersandIdx < semiColonIdx ) {
|
||||
// Then the text looks like &...&...;
|
||||
writer.write(c);
|
||||
continue;
|
||||
}
|
||||
String entityContent = string.substring(nextIdx, semiColonIdx);
|
||||
int entityValue = -1;
|
||||
int entityContentLen = entityContent.length();
|
||||
|
|
|
@ -302,5 +302,14 @@ public class StringEscapeUtilsTest extends TestCase {
|
|||
assertEquals("", StringEscapeUtils.escapeSql(""));
|
||||
assertEquals(null, StringEscapeUtils.escapeSql(null));
|
||||
}
|
||||
}
|
||||
|
||||
// Tests issue #38569
|
||||
// http://issues.apache.org/bugzilla/show_bug.cgi?id=38569
|
||||
public void testStandaloneAmphersand() {
|
||||
assertEquals("<P&O>", StringEscapeUtils.unescapeHtml("<P&O>"));
|
||||
assertEquals("test & <", StringEscapeUtils.unescapeHtml("test & <"));
|
||||
assertEquals("<P&O>", StringEscapeUtils.unescapeXml("<P&O>"));
|
||||
assertEquals("test & <", StringEscapeUtils.unescapeXml("test & <"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue