[web-devel] A string escape issue with Yesod Julius

Michael Snoyman michael at snoyman.com
Thu Nov 15 06:48:54 CET 2012


You could solve this in one of two ways:

1. Switch over to embedding `t` as JSON and concatenating in Javascript,
e.g.: [julius| str = "a" + #{toJSON t} + "bc"|]. I think we never ended up
adding the aeson instances to shakespeare-js, but I'm in favor of doing so.
2. Writing some escape algorithm on the characters. This would be more
complicated.

The reason we haven't implemented the idea that Greg mentions is that it
prevents certain use cases, such as interpolating actual Javascript code.


On Wed, Nov 14, 2012 at 12:08 PM, Dmitry Vyal <akamaus at gmail.com> wrote:

> Greetings
>
> Recently I stumbled upon an unexpected escaping problem. I hoped
> Shakespeare templates would solve these forever, but looks like it's not
> the case.
>
> For example, look at this snippet:
> Prelude Text.Julius Data.Text.Lazy Data.Text> let t = "X\"Y\"Z"; j =
> [julius| str = "a#{t}bc"; |] in putStrLn $ Data.Text.Lazy.unpack $
>  renderJavascriptUrl (\u env -> Data.Text.pack "") j
>  str = "aX"Y"Zbc";
>
> Clearly we have have a problem here. Can something be done with it?
>
> Best wishes,
> Dmitry
>
> ______________________________**_________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/**mailman/listinfo/web-devel<http://www.haskell.org/mailman/listinfo/web-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20121115/aaf67654/attachment.htm>


More information about the web-devel mailing list