BUG? Delimiters within Literal Substitutions (Have Fix)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

BUG? Delimiters within Literal Substitutions (Have Fix)

This post was updated on .

A project I've been working on is using Thymeleaf for some textual formatting (using TemplateMode.TEXT), and we've run into a issue to do with nesting delimiters/quote characters within a literal substitution, eg.:

 [( ${subject.AGE} ? |Subject's age: ${subject.AGE}| )]

In my experimentation I also tried:

 [( ${subject.AGE} ? 'Subject\'s age: ' + ${subject.AGE} )]

Which is what LiteralSubstitutionUtil.performLiteralSubstitution() produces and that didn't work either.

I've spent some time digging into the issue and have some local changes that make our templates work as expected that I can quite happy share (as it would be nice to use an official version).

There are two underlying issues:

- AbstractStandardInliner doesn't treat the pipe character as a 'quote' - so, as per my first example, including other quote characters (unpaired) caused the tag to be ignored (a problem as it's used before the LiteralSubstitutionUtil call).
- A few places in the code are not backslash escaping aware in determining the quoted section delimiters when searching for the end of enclosing blocks. My changes affect TextParsingAttributeSequenceUtil, TextParsingUtil, and AbstractStandardInliner (why the 2nd example didn't work).

We're using version 3.0.11-RELEASE.