You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/01/08 19:59:19 UTC
svn commit: r897300 -
/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
Author: markt
Date: Fri Jan 8 18:59:19 2010
New Revision: 897300
URL: http://svn.apache.org/viewvc?rev=897300&view=rev
Log:
Now the EL parser doesn't unquote stuff it shouldn't (r896589), remove the attributeValueWithEL() method as it is causing more problems than it is solving. There are still a couple of test failures but the solution I have in mind for them won't require this method.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=897300&r1=897299&r2=897300&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Fri Jan 8 18:59:19 2010
@@ -804,8 +804,8 @@
}
return v;
} else if (attr.isELInterpreterInput()) {
- v = attributeValueWithEL(this.isTagFile, v, expectedType,
- attr.getEL().getMapName());
+ v = JspUtil.interpreterCall(this.isTagFile, v, expectedType,
+ attr.getEL().getMapName(), false);
if (encode) {
return "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("
+ v + ", request.getCharacterEncoding())";
@@ -823,124 +823,6 @@
}
- /*
- * When interpreting the EL attribute value, literals outside the EL
- * must not be unescaped but the EL processor will unescape them.
- * Therefore, make sure only the EL expressions are processed by the EL
- * processor.
- */
- private String attributeValueWithEL(boolean isTag, String tx,
- Class<?> expectedType, String mapName) {
- if (tx==null) return null;
- Class<?> type = expectedType;
- int size = tx.length();
- StringBuilder output = new StringBuilder(size);
- boolean el = false;
- int i = 0;
- int mark = 0;
- char ch;
-
- while(i < size){
- ch = tx.charAt(i);
-
- // Start of an EL expression
- if (!el && i+1 < size && ch == '$' && tx.charAt(i+1)=='{') {
- if (mark < i) {
- if (output.length() > 0) {
- output.append(" + ");
- // Composite expression - must coerce to String
- type = String.class;
- }
- output.append(quote(tx.substring(mark, i)));
- }
- mark = i;
- el = true;
- i += 2;
- } else if (ch=='\\' && i+1 < size &&
- (tx.charAt(i+1)=='$' || tx.charAt(i+1)=='}')) {
- // Skip an escaped $ or }
- i += 2;
- } else if (el && ch=='}') {
- // End of an EL expression
- if (output.length() > 0) {
- output.append(" + ");
- // Composite expression - must coerce to String
- type = String.class;
- }
- if (i+1 < size) {
- // Composite expression - must coerce to String
- type = String.class;
- }
- output.append(
- JspUtil.interpreterCall(isTag,
- tx.substring(mark, i+1), type,
- mapName, false));
- mark = i + 1;
- el = false;
- ++i;
- } else {
- // Nothing to see here - move to next character
- ++i;
- }
- }
- if (!el && mark < i) {
- if (output.length() > 0) {
- output.append(" + ");
- }
- output.append(quote(tx.substring(mark, i)));
- }
- if (expectedType != type && !expectedType.isAssignableFrom(type)) {
- // Composite expression was evaluated to String
- // We must coerce it to the expected type.
- String className = JspUtil.getCanonicalName(expectedType);
- String methodName = null;
- if (expectedType.isPrimitive()) {
- if (expectedType == Boolean.TYPE) {
- className = "Boolean";
- methodName = ".booleanValue()";
- }
- else if (expectedType == Character.TYPE) {
- className = "Character";
- methodName = ".charValue()";
- }
- else if (expectedType == Byte.TYPE) {
- className = "Byte";
- methodName = ".byteValue()";
- }
- else if (expectedType == Short.TYPE) {
- className = "Short";
- methodName = ".shortValue()";
- }
- else if (expectedType == Integer.TYPE) {
- className = "Integer";
- methodName = ".intValue()";
- }
- else if (expectedType == Long.TYPE) {
- className = "Long";
- methodName = ".longValue()";
- }
- else if (expectedType == Float.TYPE) {
- className = "Float";
- methodName = ".floatValue()";
- }
- else if (expectedType == Double.TYPE) {
- className = "Double";
- methodName = ".doubleValue()";
- }
- }
- output.insert(0, "(("
- + className
- + ")org.apache.el.lang.ELSupport.coerceToType(");
- output.append(",").append(className).append(".class))");
- if (methodName != null) {
- output.insert(0, '(');
- output.append(methodName).append(')');
- }
- }
- return output.toString();
- }
-
-
/**
* Prints the attribute value specified in the param action, in the form
* of name=value string.
@@ -3000,8 +2882,8 @@
// run attrValue through the expression interpreter
String mapName = (attr.getEL() != null) ? attr.getEL()
.getMapName() : null;
- attrValue = attributeValueWithEL(this.isTagFile,
- attrValue, c[0], mapName);
+ attrValue = JspUtil.interpreterCall(this.isTagFile, attrValue,
+ c[0], mapName, false);
}
} else {
attrValue = convertString(c[0], attrValue, localName,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org