BlankBanshee / htmlcompressor

Automatically exported from code.google.com/p/htmlcompressor
Apache License 2.0
0 stars 0 forks source link

Error on embedded application/json script tag #58

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Embed a script tag with application/json content type inside your page, e.g.

<script type="application/json">{"foo": "bar"}</script>

2. Compress

What is the expected output? 

htmlcompressor should either shrink or ignore the tag

What do you see instead?

[ERROR] HtmlCompressor: "missing ; before statement" at line [3:9] during 
JavaScript compression:           "foo": "bar"
[ERROR] HtmlCompressor: "missing } in compound statement" at line [5:1] during 
JavaScript compression:
[ERROR] HtmlCompressor: "Compilation produced 2 syntax errors." at line [1:0] 
during JavaScript compression
org.mozilla.javascript.EvaluatorException: Compilation produced 2 syntax errors.
    at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor$DefaultErrorReporter.runtimeError(YuiJavaScriptCompressor.java:93)
    at org.mozilla.javascript.Parser.parse(Parser.java:392)
    at org.mozilla.javascript.Parser.parse(Parser.java:337)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
    at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.compress(YuiJavaScriptCompressor.java:53)
    at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compressJavaScript(HtmlCompressor.java:864)
    at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processScriptBlocks(HtmlCompressor.java:799)
    at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processPreservedBlocks(HtmlCompressor.java:689)
    at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:193)
    at com.googlecode.htmlcompressor.CmdLineCompressor.main(CmdLineCompressor.java:349)
Result: 1

What version of the product are you using?

1.5.2

Original issue reported on code.google.com by themal...@gmail.com on 20 Sep 2011 at 10:47

GoogleCodeExporter commented 8 years ago
Temporary solution would be wrapping script tag with <!--{{{--> <!--}}}--> skip 
comments.

Original comment by serg472@gmail.com on 21 Sep 2011 at 2:09

GoogleCodeExporter commented 8 years ago
Hi,

I can't get the temp solution to work here.  Do you mean wrap like this:

<!--
<script>
//js
</script>
-->

or like this:

<script>
<!--
//js
-->
</script>

or like this:

<!--{{{-->
<script>

</script>
<!--}}}-->

or like this:
<script>

var json = <!--{}-->

</script>

Original comment by rob.clar...@gmail.com on 23 Nov 2012 at 8:52