commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r394875 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/Entities.java test/org/apache/commons/lang/StringEscapeUtilsTest.java
Date Tue, 18 Apr 2006 07:23:06 GMT
Author: bayard
Date: Tue Apr 18 00:23:02 2006
New Revision: 394875

URL: http://svn.apache.org/viewcvs?rev=394875&view=rev
Log:
Fixing issue #38569

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java?rev=394875&r1=394874&r2=394875&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java Tue Apr
18 00:23:02 2006
@@ -820,6 +820,12 @@
                     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) {
@@ -880,6 +886,12 @@
                 int nextIdx = i+1;
                 int semiColonIdx = string.indexOf(';', nextIdx);
                 if (semiColonIdx == -1) {
+                    writer.write(c);
+                    continue;
+                }
+                int amphersandIdx = string.indexOf('&', i + 1);
+                if( amphersandIdx != -1 && amphersandIdx < semiColonIdx ) {
+                    // Then the text looks like &...&...;
                     writer.write(c);
                     continue;
                 }

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java?rev=394875&r1=394874&r2=394875&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
Tue Apr 18 00:23:02 2006
@@ -302,5 +302,14 @@
         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("&lt;P&O&gt;"));
+        assertEquals("test & <", StringEscapeUtils.unescapeHtml("test & &lt;"));
+        assertEquals("<P&O>", StringEscapeUtils.unescapeXml("&lt;P&O&gt;"));
+        assertEquals("test & <", StringEscapeUtils.unescapeXml("test & &lt;"));
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message