freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Těthal (JIRA) <j...@apache.org>
Subject [jira] [Commented] (FREEMARKER-16) js_string buit-in function escapes '/' for first character
Date Wed, 16 Mar 2016 08:06:33 GMT

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

Martin Těthal commented on FREEMARKER-16:
-----------------------------------------

You are right Daniel, in my example we need this combination:
{{ myattribute='<%= "This string $
{has?j_string?j_string?replace("'", "\\\'")} to be escaped with both" %>' }}
which is working well (tested on WebLogic 11, GlassFish 4, JBoss 5).
In my human opinon {{?j_string}} should escape also {{'}} for 2 reasons. First is the sample
above will be simplified to {{?j_string?j_string}}, second in pure Java file it is also neccessary
to escape character constant like {{'\n'}}, {{'\''}} or {{'\"'}}. The simplest way to do that
job is {{?j_string?replace("'", "\\\'")}}, but I think It is more workaround of what should
?j_string do (escapation of apostrophe).
Thanks for reply.
Martin

> 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
>            Assignee: Daniel Dekany
>            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)

Mime
View raw message