Author: bmaxwell
Date: 2012-03-09 16:44:26 -0500 (Fri, 09 Mar 2012)
New Revision: 1999
Modified:
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.properties.default
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.xml
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/AttributeParser.java
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/Parser.java
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/webapps/docs/changelog.xml
Log:
[JBPAPP-8108] fix regression Tomcat 48627 - JasperException with JSF tags and value
expressions
Modified: branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.properties.default
===================================================================
--- branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.properties.default 2012-03-09 11:13:15
UTC (rev 1998)
+++ branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.properties.default 2012-03-09 21:44:26
UTC (rev 1999)
@@ -14,7 +14,7 @@
version.minor=1
version.build=12
version.patch=0
-version.tag=GA
+version.tag=JBPAPP-8108
# ----- Default Base Path for Dependent Packages -----
# Please note this path must be absolute, not relative,
Modified: branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.xml
===================================================================
--- branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.xml 2012-03-09 11:13:15 UTC (rev 1998)
+++ branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/build.xml 2012-03-09 21:44:26 UTC (rev 1999)
@@ -18,7 +18,7 @@
<property name="version.minor" value="1" />
<property name="version.build" value="0" />
<property name="version.patch" value="0" />
- <property name="version.tag" value="SNAPSHOT" />
+ <property name="version.tag" value="JBPAPP-8108"
/>
<property name="version"
value="${version.major}.${version.minor}.${version.build}.${version.tag}" />
<property name="version.number"
value="${version.major}.${version.minor}.${version.build}.${version.patch}"
/>
Modified:
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/AttributeParser.java
===================================================================
---
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/AttributeParser.java 2012-03-09
11:13:15 UTC (rev 1998)
+++
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/AttributeParser.java 2012-03-09
21:44:26 UTC (rev 1999)
@@ -24,7 +24,7 @@
* "\${1+1}". After unquoting, both appear as "${1+1}" but the first
should
* evaluate to "2" and the second to "${1+1}". Literal \, $ and #
need special
* treatment to ensure there is no ambiguity. The JSP attribute unquoting
- * covers \\, \", \', \$, \#, %\>, <\%, ' and "
+ * covers \\, \", \', \$, \#, %\>, <\%, &apos; and
&quot;
*/
public class AttributeParser {
@@ -43,13 +43,16 @@
* scripting expressions.
* @param isELIgnored Is expression language being ignored on the page
* where the JSP attribute is defined.
+ * @param isDeferredSyntaxAllowedAsLiteral
+ * Are deferred expressions treated as literals?
* @return An unquoted JSP attribute that, if it contains
* expression language can be safely passed to the EL
* processor without fear of ambiguity.
*/
public static String getUnquoted(String input, char quote,
- boolean isELIgnored) {
+ boolean isELIgnored, boolean isDeferredSyntaxAllowedAsLiteral) {
return (new AttributeParser(input, quote, isELIgnored,
+ isDeferredSyntaxAllowedAsLiteral,
STRICT_QUOTE_ESCAPING)).getUnquoted();
}
@@ -62,15 +65,18 @@
* scripting expressions.
* @param isELIgnored Is expression language being ignored on the page
* where the JSP attribute is defined.
+ * @param isDeferredSyntaxAllowedAsLiteral
+ * Are deferred expressions treated as literals?
* @param strict The value to use for STRICT_QUOTE_ESCAPING.
* @return An unquoted JSP attribute that, if it contains
* expression language can be safely passed to the EL
* processor without fear of ambiguity.
*/
protected static String getUnquoted(String input, char quote,
- boolean isELIgnored, boolean strict) {
+ boolean isELIgnored, boolean isDeferredSyntaxAllowedAsLiteral,
+ boolean strict) {
return (new AttributeParser(input, quote, isELIgnored,
- strict)).getUnquoted();
+ isDeferredSyntaxAllowedAsLiteral, strict)).getUnquoted();
}
/* The quoted input string. */
@@ -83,6 +89,9 @@
* treated as literals rather than quoted values. */
private final boolean isELIgnored;
+ /* Are deferred expression treated as literals */
+ private final boolean isDeferredSyntaxAllowedAsLiteral;
+
/* Overrides the STRICT_QUOTE_ESCAPING. Used for Unit tests only. */
private final boolean strict;
@@ -109,12 +118,15 @@
* @param strict
*/
private AttributeParser(String input, char quote,
- boolean isELIgnored, boolean strict) {
+ boolean isELIgnored, boolean isDeferredSyntaxAllowedAsLiteral,
+ boolean strict) {
this.input = input;
this.quote = quote;
// If quote is null this is a scriptign expressions and any EL syntax
// should be ignored
this.isELIgnored = isELIgnored || (quote == 0);
+ this.isDeferredSyntaxAllowedAsLiteral =
+ isDeferredSyntaxAllowedAsLiteral;
this.strict = strict;
this.type = getType(input);
this.size = input.length();
@@ -151,22 +163,27 @@
char ch = nextChar();
if (!isELIgnored && ch == '\\') {
if (type == 0) {
- type = '$';
+ result.append("\\");
+ } else {
+ result.append(type);
+ result.append("{'\\\\'}");
}
- result.append(type);
- result.append("{'\\\\'}");
} else if (!isELIgnored && ch == '$' &&
lastChEscaped){
if (type == 0) {
- type = '$';
+ result.append("\\$");
+ } else {
+ result.append(type);
+ result.append("{'$'}");
}
- result.append(type);
- result.append("{'$'}");
} else if (!isELIgnored && ch == '#' &&
lastChEscaped){
+ // Note if isDeferredSyntaxAllowedAsLiteral==true, \# will
+ // not be treated as an escape
if (type == 0) {
- type = '$';
+ result.append("\\#");
+ } else {
+ result.append(type);
+ result.append("{'#'}");
}
- result.append(type);
- result.append("{'#'}");
} else if (ch == type){
if (i < size) {
char next = input.charAt(i);
@@ -197,8 +214,8 @@
private void parseEL() {
boolean endEL = false;
boolean insideLiteral = false;
+ char literalQuote = 0;
while (i < size && !endEL) {
- char literalQuote = '\'';
char ch = nextChar();
if (ch == '\'' || ch == '\"') {
if (insideLiteral) {
@@ -261,7 +278,10 @@
} else if (ch == '\\' && i + 1 < size) {
ch = input.charAt(i + 1);
if (ch == '\\' || ch == '\"' || ch == '\''
||
- (!isELIgnored && (ch == '$' || ch == '#')))
{
+ (!isELIgnored &&
+ (ch == '$' ||
+ (!isDeferredSyntaxAllowedAsLiteral &&
+ ch == '#')))) {
i += 2;
lastChEscaped = true;
} else {
@@ -311,13 +331,13 @@
int j = 0;
int len = value.length();
char current;
-
+
while (j < len) {
current = value.charAt(j);
if (current == '\\') {
// Escape character - skip a character
j++;
- } else if (current == '#') {
+ } else if (current == '#' &&
!isDeferredSyntaxAllowedAsLiteral) {
if (j < (len -1) && value.charAt(j + 1) == '{') {
return '#';
}
Modified:
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/Parser.java
===================================================================
---
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/Parser.java 2012-03-09
11:13:15 UTC (rev 1998)
+++
branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/java/org/apache/jasper/compiler/Parser.java 2012-03-09
21:44:26 UTC (rev 1999)
@@ -247,7 +247,8 @@
quote = watch.charAt(0);
}
ret = AttributeParser.getUnquoted(reader.getText(start, stop),
- quote, pageInfo.isELIgnored());
+ quote, pageInfo.isELIgnored(),
+ pageInfo.isDeferredSyntaxAllowedAsLiteral());
} catch (IllegalArgumentException iae) {
err.jspError(start, iae.getMessage());
}
Modified: branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/webapps/docs/changelog.xml
===================================================================
--- branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/webapps/docs/changelog.xml 2012-03-09 11:13:15
UTC (rev 1998)
+++ branches/JBOSSWEB_2_1_12_GA_JBPAPP-8108/webapps/docs/changelog.xml 2012-03-09 21:44:26
UTC (rev 1999)
@@ -50,6 +50,11 @@
<fix>
EL escaping fixes. (markt)
</fix>
+ <fix>
+ <bug>48627</bug>: Fix regression in re-factored EL parsing. Keep
+ literals as literals and handle deferredSyntaxAllowedAsLiteral.
+ (kkolinko)
+ </fix>
</changelog>
</subsection>