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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]