LCHCAPITALHUMAIN / htmlcompressor

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

severe bug in HtmlCompressor:preserveBlocks #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
compress a large jsp page (e.g. 2MBytes) leads to messed up html code with 
%%%COMPRESS~EVENT~1.000%%% to %%%COMPRESS~EVENT~11.687%%% fragments in the ouput

caused by HtmlCompressor:preserveBlocks
calls of java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0}%%%", new 
Object[] {Integer.valueOf(index)})

have to be MessageFormat.format("%%%COMPRESS~EVENT~{0,number,#}%%%", new 
Object[] {Integer.valueOf(index)})

can be reproduced with this sample code

for(int index=995; index< 1005; index++){

    // all COMPRESS~???~ patterns are wrong for i>=1000 (at least in HtmlCompressor.java)
    String bad  = java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0}%%%"         , new Object[] {Integer.valueOf(index)});
    String good = java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0,number,#}%%%", new Object[] {Integer.valueOf(index)});
    System.out.println("bad: "+bad +", good:" +good);
}

with corrected code in HtmlCompressor, html output is good

Original issue reported on code.google.com by m.konic...@gmail.com on 2 Feb 2011 at 8:31

GoogleCodeExporter commented 9 years ago
Wow, that's something I didn't think about. Thanks for debugging, fixed in 0.9.9

Original comment by serg472@gmail.com on 3 Feb 2011 at 2:08