From: markt Date: Mon, 2 Nov 2009 00:30:55 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47331 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d8e02ddb4ba2e3b6c7608c1c5ad30a6ba572dc0d;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47331 Uninterpreted tags are essentially template text so apply the rules of JSp.2.2 there too. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@831785 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/Validator.java b/java/org/apache/jasper/compiler/Validator.java index fdc5a568d..1d5ddfbd4 100644 --- a/java/org/apache/jasper/compiler/Validator.java +++ b/java/org/apache/jasper/compiler/Validator.java @@ -731,9 +731,16 @@ class Validator { int attrSize = attrs.getLength(); Node.JspAttribute[] jspAttrs = new Node.JspAttribute[attrSize]; for (int i = 0; i < attrSize; i++) { + // JSP.2.2 - '#{' not allowed in template text + String value = attrs.getValue(i); + if (!pageInfo.isDeferredSyntaxAllowedAsLiteral()) { + if (containsDeferredSyntax(value)) { + err.jspError(n, "jsp.error.el.template.deferred"); + } + } jspAttrs[i] = getJspAttribute(null, attrs.getQName(i), - attrs.getURI(i), attrs.getLocalName(i), attrs - .getValue(i), n, false); + attrs.getURI(i), attrs.getLocalName(i), value, n, + false); } n.setJspAttributes(jspAttrs); } @@ -741,6 +748,31 @@ class Validator { visitBody(n); } + /* + * Look for a #{ sequence that isn't preceded by \. + */ + private boolean containsDeferredSyntax(String value) { + if (value == null) { + return false; + } + + int i = 0; + int len = value.length(); + boolean prevCharIsEscape = false; + while (i < value.length()) { + char c = value.charAt(i); + if (c == '#' && (i+1) < len && value.charAt(i+1) == '{' && !prevCharIsEscape) { + return true; + } else if (c == '\\') { + prevCharIsEscape = true; + } else { + prevCharIsEscape = false; + } + i++; + } + return false; + } + public void visit(Node.CustomTag n) throws JasperException { TagInfo tagInfo = n.getTagInfo(); @@ -1063,7 +1095,7 @@ class Validator { String expectedType = null; if (tldAttrs[j].isDeferredMethod()) { - // The String litteral must be castable to what is declared as type + // The String literal must be castable to what is declared as type // for the attribute String m = tldAttrs[j].getMethodSignature(); if (m != null) { diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 29b5cba5a..0d3f63578 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -443,7 +443,7 @@ jsp.error.prefix.use_before_dcl=The prefix {0} specified in this tag directive h jsp.exception=An exception occurred processing JSP page {0} at line {1} # JSP 2.1 -jsp.error.el.template.deferred=#{..} is not allowed in template text +jsp.error.el.template.deferred=#{...} is not allowed in template text jsp.error.el.parse={0} : {1} jsp.error.page.invalid.deferredsyntaxallowedasliteral=Page directive: invalid value for deferredSyntaxAllowedAsLiteral jsp.error.tag.invalid.deferredsyntaxallowedasliteral=Tag directive: invalid value for deferredSyntaxAllowedAsLiteral