On 24/04/2014 10:00, Konstantin Kolinko wrote: > 2014-04-24 12:35 GMT+04:00 <ma...@apache.org>: >> Author: markt >> Date: Thu Apr 24 08:35:06 2014 >> New Revision: 1589635
<snip/> >> Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java >> URL: >> http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java?rev=1589635&r1=1589634&r2=1589635&view=diff >> ============================================================================== >> --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java >> (original) >> +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java Thu >> Apr 24 08:35:06 2014 <snip/> >> @@ -235,6 +242,98 @@ public class ELParser { >> return buf.toString(); >> } >> >> + >> + /** >> + * Escape '\\', '$' and '#', inverting the unescaping performed in >> + * {@link #skipUntilEL()}. >> + * >> + * @param input Non-EL input to be escaped >> + * @param isDeferredSyntaxAllowedAsLiteral >> + * >> + * @return The escaped version of the input >> + */ >> + private static String escapeLiteralExpression(String input, >> + boolean isDeferredSyntaxAllowedAsLiteral) { >> + int len = input.length(); >> + int lastAppend = 0; >> + StringBuilder output = null; >> + for (int i = 0; i < len; i++) { >> + char ch = input.charAt(i); >> + if (ch =='$' || (!isDeferredSyntaxAllowedAsLiteral && ch == >> '#')) { >> + if (output == null) { >> + output = new StringBuilder(len + 20); >> + } > > String.subSequence() = String.substring(), > but StringBuilder.append uses array copy with string but iteration > with a sequence StringBuilder.append also does a "instanceof" check and appends if the CharSequence is an instance of String. While I'm happy to clean up trunk I don't see the point in back-porting. <snip/> >> + /** >> + * Escape '\\', '\'' and '\"', inverting the unescaping performed in >> + * {@link #skipUntilEL()}. >> + * >> + * @param input Non-EL input to be escaped >> + * @param isDeferredSyntaxAllowedAsLiteral >> + * >> + * @return The escaped version of the input >> + */ >> + private static String escapeELText(String input) { >> + int len = input.length(); >> + char quote = 0; >> + int lastAppend = 0; >> + >> + if (len > 1) { >> + // Might be quoted >> + quote = input.charAt(0); >> + if (quote == '\'' || quote == '\"') { >> + if (input.charAt(len - 1) != quote) { >> + throw new IllegalArgumentException(Localizer.getMessage( >> + >> "org.apache.jasper.compiler.ELParser.invalidQuotesForStringLiteral", > > The LocalString.properties change is missing from backport. See r1587887 > BTW, maybe > s /must be contained with/must be contained within/ > in message text. I'll get that fixed. <snip/> >> + StringBuilder output = null; >> + for (int i = lastAppend; i < len; i++) { >> + char ch = input.charAt(i); >> + if (ch == '\\' || ch == quote) { >> + if (output == null) { >> + output = new StringBuilder(len + 20); >> + output.append(quote); >> + } >> + output.append(input.subSequence(lastAppend, i)); > > Ditto, s/subSequence/substring/. Ditto, change is unnecessary. >> + lastAppend = i + 1; >> + output.append('\\'); >> + output.append(ch); >> + } >> + } >> + if (output == null) { >> + return input; >> + } else { >> + output.append(input.substring(lastAppend, len)); >> + if (quote != 0) { >> + output.append(quote); >> + } >> + return output.toString(); >> + } >> + } >> + >> + >> /* >> * @return true if there is something left in EL expression buffer other >> * than white spaces. <snip/> Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org