Escaping a clearsilver variable for use as a javascript parameter from an href
-
05-07-2019 - |
Question
I'm using a clearsilver variable as a parameter to a javascript function, from an href. Like this:
<a href="javascript:foo('<?cs var: js_escape(bar) ?>');"><span>
This works great, until the cs variable contains quotes.
Anyone have experience with this? Is there some ordering of escaping that will work for this, or do I need to find a variable that doesn't have quotes in it?
Solution
Did some more testing, this works:
<a href="javascript:foo('<?cs var: html_escape(js_escape(bar)) ?>');">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow