Correctly coerce the empty string to zero when used as an operand in EL arithmetic.
Patch provided by gbt.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@
1099789 13f79535-47bb-0310-9956-
ffa450edef68
if (isNumber(obj)) {
return coerce((Number) obj);
}
- if (obj instanceof String) {
- return coerce((String) obj);
- }
if (obj == null || "".equals(obj)) {
return coerce(ZERO);
}
-
+ if (obj instanceof String) {
+ return coerce((String) obj);
+ }
if (obj instanceof Character) {
return coerce(Short.valueOf((short) ((Character) obj).charValue()));
}
assertEquals("1.1",
String.valueOf(ELArithmetic.mod(a, b)));
}
+
+ public void testBug47371() throws Exception {
+ assertEquals("1",
+ String.valueOf(ELArithmetic.add("", Integer.valueOf(1))));
+ }
}
</subsection>
<subsection name="Jasper">
<changelog>
+ <fix>
+ <bug><47371/bug>: Correctly coerce the empty string to zero when used as
+ an operand in EL arithmetic. Patch provided by gbt. (markt)
+ </fix>
<add>
Label JSP/tag file line and column numbers when reporting errors since
it may not be immediately obvious what the numbers represent. (markt)