Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 23636 invoked from network); 19 Oct 2008 21:27:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Oct 2008 21:27:38 -0000 Received: (qmail 39264 invoked by uid 500); 19 Oct 2008 21:27:33 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 39191 invoked by uid 500); 19 Oct 2008 21:27:33 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 39179 invoked by uid 99); 19 Oct 2008 21:27:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Oct 2008 14:27:33 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Oct 2008 21:26:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8109C238889E; Sun, 19 Oct 2008 14:26:40 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r706071 - /tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Date: Sun, 19 Oct 2008 21:26:40 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081019212640.8109C238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Sun Oct 19 14:26:40 2008 New Revision: 706071 URL: http://svn.apache.org/viewvc?rev=706071&view=rev Log: Fix the remaining EL / TCK issues. With this patch the EL TCK tests pass and my test cases for bugs 42565, 44994, 45015, 45451, 45427, 45511 and some additional tests for edge cases all pass. 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=706071&r1=706070&r2=706071&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Sun Oct 19 14:26:40 2008 @@ -806,8 +806,8 @@ } return v; } else if (attr.isELInterpreterInput()) { - v = JspUtil.interpreterCall(this.isTagFile, v, expectedType, - attr.getEL().getMapName(), false); + v = attributeValueWithEL(this.isTagFile, v, expectedType, + attr.getEL().getMapName()); if (encode) { return "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(" + v + ", request.getCharacterEncoding())"; @@ -824,6 +824,68 @@ } } + + /* + * 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; + int size = tx.length(); + StringBuffer output = new StringBuffer(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(" + "); + } + 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(" + "); + } + output.append( + JspUtil.interpreterCall(isTag, + tx.substring(mark, i+1), expectedType, + 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))); + } + return output.toString(); + } + + /** * Prints the attribute value specified in the param action, in the form * of name=value string. @@ -2836,8 +2898,8 @@ // run attrValue through the expression interpreter String mapName = (attr.getEL() != null) ? attr.getEL() .getMapName() : null; - attrValue = JspUtil.interpreterCall(this.isTagFile, - attrValue, c[0], mapName, false); + attrValue = attributeValueWithEL(this.isTagFile, + attrValue, c[0], mapName); } } 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