You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Daniel Dekany (JIRA)" <ji...@apache.org> on 2016/03/14 15:35:33 UTC

[jira] [Comment Edited] (FREEMARKER-16) js_string buit-in function escapes '/' for first character

    [ https://issues.apache.org/jira/browse/FREEMARKER-16?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15193373#comment-15193373 ] 

Daniel Dekany edited comment on FREEMARKER-16 at 3/14/16 2:35 PM:
------------------------------------------------------------------

I have fixed the documentation (will be visible when 2.3.24 is released). As of escaping for generating JSP, that can only be part of FreeMarker if it works in all cases, and of course it's more complex than escaping {{'}} and {{"}}. Like it has to escape {{${}} and {{#{}} too, and is must generate escapes like {{\n}}, which doesn't exist in JSP. But the trickier part is with {{\&quot;}} and {{\&amp;}}, which are alternative ways of escaping {{'}} and {{"}}, however they themselves can't be escaped. So if you have {{$\{s?jsp_string}}}, and {{s}} contains {{\&quot;}}, the only way I can escape it is with EL: {{${'&'}quot;}}. Kind of insane...


was (Author: ddekany):
I have fixed the documentation (will be visible when 2.3.24 is released). As of escaping for generating JSP, that can only be part of FreeMarker if it works in all cases, and of course it's more complex than escaping {{'}} and {{"}}. Like it has to escape {{${}} and {{#{}} too, and is must generate escapes like {{\n}}, which doesn't exist in JSP. But the trickier part is with {{&quot;}} and {{&amp;}}, which are alternative ways of escaping {{'}} and {{"}}, however they themselves can't be escaped. So if you have {{$\{s?jsp_string}}}, and {{s}} contains {{&quot;}}, the only way I can escape it is with EL: {{${'&'}quot;}}. Kind of insane...

> js_string buit-in function escapes '/' for first character
> ----------------------------------------------------------
>
>                 Key: FREEMARKER-16
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-16
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.23
>            Reporter: Martin Těthal
>            Priority: Minor
>
> ${"bar/foo"?js_string} returns "bar/foo"
> but
> ${"/foo"?js_string} returns "\/foo" (the first slash character is escaped by backslash).
> I think the problem is from version 2.3.1 as documentation says:
> Starting from FreeMarker 2.3.1, it also escapes > as \> (to avoid </script>).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)