Menu

#101 Escaping "#{" sequences often fails

undecided
closed-fixed
nobody
None
6
2014-10-12
2005-09-27
Anonymous
No

The following <legal> escapes fail:

1:

value="#${"\{"}${bean.ClassName}.lastMessage}" />

gives
C:\data\workspace\src>java
com.abnamro.midms.export.JSFGenerator
- Exception <Token manager error:
freemarker.core.TokenMgrError: Lexical error at line 7,
column 31. Encountered: "{" (
123), after : "\"\\"> caught during initialization of
template jsf.ftl
0 [main] FATAL FreeMarker - Exception <Token
manager error: freemarker.core.TokenMgrError: Lexical
error at line 7, col
umn 31. Encountered: "{" (123), after : "\"\\"> caught
during initialization of template jsf.ftl

2:

value="${"#\{"}${bean.ClassName}.lastMessage}" />

C:\data\workspace\src>java
com.abnamro.midms.export.JSFGenerator
- Exception <Token manager error:
freemarker.core.TokenMgrError: Lexical error at line 7,
column 31. Encountered: "{" (
123), after : "\"#\\"> caught during initialization of
template jsf.ftl
0 [main] FATAL FreeMarker - Exception <Token
manager error: freemarker.core.TokenMgrError: Lexical
error at line 7, col
umn 31. Encountered: "{" (123), after : "\"#\\"> caught
during initialization of template jsf.ftl

Even this fails:
value="${"#\x7B"}${bean.ClassName}.lastMessage}" />

C:\data\workspace\src>java
com.abnamro.midms.export.JSFGenerator
- Exception <Unexpected end of file reached.
> caught during initialization of template jsf.ftl
0 [main] FATAL FreeMarker - Exception <Unexpected
end of file reached.
> caught during initialization of template jsf.ftl

There are some other variants on this theme that fail as
well.

One of the few things that do work is something like:
value="${r"#{"}${bean.ClassName}.lastMessage}" />

Regards,

falco.paul@nl.abnamro.com

Discussion

  • Dániel Dékány

    • priority: 5 --> 6
     
  • Dániel Dékány

    Logged In: YES
    user_id=546667

    Wow... For me it basically boils down to two things:
    - The \{ escape simply doesn't work... like if we don't support
    it. ${"\{"} will give the same error as an unknown escape like
    as ${"\%"}.
    - The \xXXXX escape will be resolved before some other string
    literal parsing. This way ${"$\x7B"} will be equivalent with
    ${"${"} and hence will cause syntax error.

    But, until it is fixed and released, and actually even if it will be
    fixed: In the cases above you don't have to escape the {, since
    it is not directly preceded by $ or #. So you can simply write:
    value="#${"{"}${bean.ClassName}.lastMessage}" />
    which works right now. Also if sometimes you really had to
    escape {, you might be better with raw string literals like
    ${r"#{foo}"}, that also work right now, and is less confusing for
    the eyes.

     
  • Dániel Dékány

    • status: open --> open-accepted
     
  • Dániel Dékány

    • status: open-accepted --> closed-fixed
    • Group: --> undecided
     
  • Dániel Dékány

    This was fixed ages ago, just we have forgotten to close it...

     

Log in to post a comment.

Auth0 Logo