Author: markt
Date: Mon Nov 2 00:30:55 2009
New Revision: 831785
URL: http://svn.apache.org/viewvc?rev=831785&view=rev
Log:
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.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Validator.java
tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Validator.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Validator.java?rev=831785&r1=831784&r2=831785&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Validator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Validator.java Mon Nov 2
00:30:55 2009
@@ -731,9 +731,16 @@
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 @@
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 @@
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) {
Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=831785&r1=831784&r2=831785&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
(original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Mon
Nov 2 00:30:55 2009
@@ -443,7 +443,7 @@
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]