Adding more checks for valid hex string
diff --git a/1.5/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java b/1.5/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java
index 05a8d3b..d5bd6f0 100644
--- a/1.5/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java
+++ b/1.5/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java
@@ -365,17 +365,27 @@
case '%':
if (i + 4 < length) {
String hexStr = html.substring(i + 1, i + 5);
- try {
- int codePoint = Integer.parseInt(hexStr, 16);
- char[] c = UCharacter.toChars(codePoint);
- result.append(c);
- i += 4;
- break;
- } catch (NumberFormatException e) {
- // wasn't a valid hex string..
- // fall through to the result.append(ch)
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
+ boolean validHextStr = true;
+ for (int j = 0; j < hexStr.length(); j++) {
+ char c = hexStr.charAt(j);
+ if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
+ validHextStr = false;
+ break;
+ }
+ }
+ if (validHextStr) {
+ try {
+ int codePoint = Integer.parseInt(hexStr, 16);
+ char[] c = UCharacter.toChars(codePoint);
+ result.append(c);
+ i += 4;
+ break;
+ } catch (NumberFormatException e) {
+ // wasn't a valid hex string..
+ // fall through to the result.append(ch)
+ } catch (Exception e) {
+ CommonPlugin.getDefault().getLogger().logError(e);
+ }
}
}
result.append(ch);