// Quoting <% and %>
assertEquals("hello <% world", evalAttr("hello <\\% world", '\"'));
assertEquals("hello %> world", evalAttr("hello %> world", '\"'));
+
+ // Test that the end of literal in EL expression is recognized in
+ // parseEL(), be it quoted with single or double quotes. That is, that
+ // AttributeParser correctly switches between parseLiteral and parseEL
+ // methods.
+ //
+ // The test is based on the difference in how the '\' character is printed:
+ // when in parseLiteral \\${ will be printed as ${'\'}${, but if we are still
+ // inside of parseEL it will be printed as \${, thus preventing the EL
+ // expression that follows from being evaluated.
+ //
+ assertEquals("foo\\bar\\baz", evalAttr("${\'foo\'}\\\\${\'bar\'}\\\\${\'baz\'}", '\"'));
+ assertEquals("foo\\bar\\baz", evalAttr("${\'foo\'}\\\\${\\\"bar\\\"}\\\\${\'baz\'}", '\"'));
+ assertEquals("foo\\bar\\baz", evalAttr("${\\\"foo\\\"}\\\\${\'bar\'}\\\\${\\\"baz\\\"}", '\"'));
+ assertEquals("foo\\bar\\baz", evalAttr("${\"foo\"}\\\\${\\\'bar\\\'}\\\\${\"baz\"}", '\''));
}
- public void testScriptExpressiinLiterals() {
+ public void testScriptExpressionLiterals() {
assertEquals(" \"hello world\" ", parseScriptExpression(
" \"hello world\" ", (char) 0));
assertEquals(" \"hello \\\"world\" ", parseScriptExpression(