3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1633 Views |
-
Escaping values in a JavaScript string

7 June 2011 at 7:50am Last edited: 7 June 2011 7:52am
So I've been using the HTML5 boilerplate project as a foundation for my page templates. At the bottom of the main page template I have the following markup:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write('<script src="$ThemeDir/js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>The problem I'm experiencing is the value \x3C/script> in the 2nd line is being converted to </script>. I believe this is being done by the SilverStripe template engine.
Is there a way to prevent this conversion from happening so that it remains as \x3C/script>?
-
Re: Escaping values in a JavaScript string

7 June 2011 at 8:45am
I hit the very same problem today...have been chasing down a fix. Once I find one I will pass it along...and I'll keep an eye on this thread in case you find one before me.
-
Re: Escaping values in a JavaScript string

7 June 2011 at 9:22am
I went back to using the original unescaped version: "%3E%3C/script%3E" instead of "\x3C/script>"
I believe the new way H5BP is being converted to a normal PHP string...so try the old way like I did or try to find a different escaping method.
-
Re: Escaping values in a JavaScript string

7 June 2011 at 9:24am
Just discovered putting an additional slash in did the trick as well
\\x3C/script>
| 1633 Views | ||
|
Page:
1
|
Go to Top |


