commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r469661 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/Entities.java test/org/apache/commons/lang/EntitiesTest.java
Date Tue, 31 Oct 2006 21:34:04 GMT
Author: bayard
Date: Tue Oct 31 13:34:03 2006
New Revision: 469661

URL: http://svn.apache.org/viewvc?view=rev&rev=469661
Log:
Applying unit test and fix for #LANG-292. Also fixes a couple of problems with the unescape(Writer..)
overload that came up

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/EntitiesTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java?view=diff&rev=469661&r1=469660&r2=469661
==============================================================================
--- 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 Oct
31 13:34:03 2006
@@ -847,6 +847,9 @@
                             } else {
                                 entityValue = Integer.parseInt(entityName.substring(1));
                             }
+                            if (entityValue > 0xFFFF) {
+                                entityValue = -1;
+                            }
                         } catch (NumberFormatException ex) {
                             entityValue = -1;
                         }
@@ -917,13 +920,17 @@
                                     case 'X' :
                                     case 'x' : {
                                         entityValue = Integer.parseInt(entityContent.substring(2),
16);
+                                        break;
                                     }
                                     default : {
                                         entityValue = Integer.parseInt(entityContent.substring(1),
10);
                                     }
                                 }
+                                if (entityValue > 0xFFFF) {
+                                    entityValue = -1;
+                                }
                             } catch (NumberFormatException e) {
-                                // ignore the escaped value content
+                                entityValue = -1;
                             }
                         }
                     } else { //escaped value content is an entity name

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/EntitiesTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/EntitiesTest.java?view=diff&rev=469661&r1=469660&r2=469661
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/EntitiesTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/EntitiesTest.java Tue
Oct 31 13:34:03 2006
@@ -197,5 +197,13 @@
         assertEquals(" ", e.escape("\u00A0"));
     }
 
+    public void testNumberOverflow() throws Exception {
+        doTestUnescapeEntity("�", "�");
+        doTestUnescapeEntity("x�y", "x�y");
+        doTestUnescapeEntity("�", "�");
+        doTestUnescapeEntity("x�y", "x�y");
+    }
+
+
 }
 



---------------------------------------------------------------------
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