ASF Bugzilla – Attachment 21982 Details for
Bug 43285
Missing EL Coercion causes argument type mismatch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch taking care of primitive types (configurable)
tomcat-jasper-el-coerce-configurable.patch (text/plain), 1.79 KB, created by
Nils Eckert
on 2008-05-19 04:23:09 UTC
(
hide
)
Description:
Proposed patch taking care of primitive types (configurable)
Filename:
MIME Type:
Creator:
Nils Eckert
Created:
2008-05-19 04:23:09 UTC
Size:
1.79 KB
patch
obsolete
>Index: java/org/apache/el/parser/AstValue.java >=================================================================== >--- java/org/apache/el/parser/AstValue.java (revision 656725) >+++ java/org/apache/el/parser/AstValue.java (working copy) >@@ -37,7 +37,13 @@ > * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$ > */ > public final class AstValue extends SimpleNode { >+ private static final boolean STRICT_JSP_COMPLIANCE; > >+ static { >+ STRICT_JSP_COMPLIANCE = "true".equals(System.getProperty( >+ "org.apache.catalina.STRICT_JSP_COMPLIANCE", "false")); >+ } >+ > protected static class Target { > protected Object base; > >@@ -129,12 +135,26 @@ > Target t = getTarget(ctx); > ctx.setPropertyResolved(false); > ELResolver resolver = ctx.getELResolver(); >- resolver.setValue(ctx, t.base, t.property, >- // coerce to the expected type >- ELSupport.coerceToType(value, >- resolver.getType(ctx, t.base, t.property))); >+ >+ // coerce to the expected type >+ Class<?> targetClass = resolver.getType(ctx, t.base, t.property); >+ if (STRICT_JSP_COMPLIANCE == true >+ || !isAssignable(value, targetClass)) { >+ value = ELSupport.coerceToType(value, targetClass); >+ } >+ >+ resolver.setValue(ctx, t.base, t.property, value); > } > >+ private boolean isAssignable(Object value, Class<?> targetClass) { >+ if (value != null && targetClass.isPrimitive()) { >+ return false; >+ } else if (value != null && !targetClass.isInstance(value)) { >+ return false; >+ } >+ return true; >+ } >+ > public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) > throws ELException { > Target t = getTarget(ctx);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43285
:
20757
|
20759
|
21962
|
21981
|
21982
|
22028