Ignore my last post, I should've scrolled a lot further down the WHATWG page , generally CDATA is called a "bogus comment" there but <script/> and <style/> tags are exceptions and CDATA works in a limited way.

Sorry for the noise,
Tobias

btw, a bigger issue (but one I'm too scared to touch) is that Wicket by default uses "text/html" as MIME type and according to the WHATWG wiki , CDATA has *no* effect at all unless you use an XML MIME type (application/xml or text/xhtml+xml):

https://wiki.whatwg.org/wiki/HTML_vs._XHTML

Not sure how up-to-date this wiki page really is and whether current browser implementations agree with what the page says (I didn't check this) ... but this would mean that the whole "<![CDATA[" stuff could most likely be dropped from JavascriptUtils , at least if one only cares about modern browsers.

Cheers,
Tobias

Hi Sven,

Thanks for your response! After reading a very informative blog post by one of the Chrome DevTools developers (https://mathiasbynens.be/notes/etago), I learned there is certain content that is perfectly fine in pure Javascript but literally *impossible* to include using an inline <script/> tag, simply because there's no way to escape stuff properly.

So despite my earlier post, I now think what JavascriptUtils#writeJavaScript() does is actually correct - there's simply no way to do any better.


--
Tobias Gierke
Software Developer

Voipfuture GmbH   Wendenstr. 4   20097 Hamburg   Germany
Phone +49 40 688 9001 64   Fax +49 40 688 9001 99
Managing Directors   Jan Bastian   Eyal Ullert
Commercial Court AG Hamburg   HRB 109896   VAT ID DE263738086


Reply via email to