Bug 51049

Summary: [PATCH] <junitreport> produces broken "Properties >>" link
Product: Ant Reporter: Markus Keller <markuskeller>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: CLOSED FIXED    
Severity: normal CC: acwwat, david.stdenis, dzidzitop, jglick
Priority: P2    
Version: 1.8.2   
Target Milestone: 1.8.3   
Hardware: PC   
OS: All   
Attachments: HTML file with broken Properties link
Patch for escaping newline chars properly in junit report stylesheets

Description Markus Keller 2011-04-11 11:00:12 UTC
The <junit> task from Ant 1.7.1 produced XML files where the values <property> elements could contain newline characters, e.g.:

    <property name="ant.core.lib" value="C:\e\i\I20110127-2034-3.7M5-clean\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant.jar" />
    <property name="line.separator" value="
" />

The <junitreport> converted this to HTML files where the value in the JavaScript had a single space instead of the line separator characters:

        cur['line.separator'] = ' ';

This was valid JavaScript.


With Ant 1.8.2, the value in the XML got properly escaped:

    <property name="ant.core.lib" value="C:\e\i\N20110407-2000\plugins\org.apache.ant_1.8.2.v20110117-1200\lib\ant.jar" />
    <property name="line.separator" value="&#xd;&#xa;" />

But now, the <junitreport> task creates JavaScript like this, which is invalid:

        cur['line.separator'] = '

';
    
        cur['os.arch'] = 'x86';

=> There are 2 line separators in the HTML file. Should be something like:

         cur['line.separator'] = '&#xd;&#xa;';
Comment 1 Markus Keller 2011-04-11 11:01:31 UTC
Created attachment 26873 [details]
HTML file with broken Properties link
Comment 2 Anthony Wat 2011-05-16 03:53:58 UTC
It looks like the XSL stylesheets junit-frames.xsl and junit-noframes.xsl are not escaping newline characters in the javascript sections. I found this blog page that pretty much sums up the problem and remedy:

http://zanstra.com/base/blog/xslt_string_escape

Specifically, the stylesheets should replace &#xd; with \r and &#xa; with \n. I'll attach a patch that involves updating the JS-escape template in the stylesheet shortly.
Comment 3 Anthony Wat 2011-05-16 04:09:49 UTC
Created attachment 27001 [details]
Patch for escaping newline chars properly in junit report stylesheets

The xsl files to patch are in ant/src/etc and named the same as the diffs files respectively.
Comment 4 Markus Keller 2011-10-27 13:21:49 UTC
Ping. Could this go into 1.8.3?
Comment 5 Jesse Glick 2011-11-09 19:45:26 UTC
Committed revision 1199931. Please verify fix in a nightly build if you have a moment.
Comment 6 Markus Keller 2012-01-11 17:35:10 UTC
Looks good, thanks. Sorry for the delay.

Tested with nightly build from https://builds.apache.org/view/A-F/view/Ant/job/Ant_JDK_1.4/486/artifact/trunk/build/lib/
Comment 7 Stefan Bodewig 2013-08-16 06:21:28 UTC
*** Bug 55425 has been marked as a duplicate of this bug. ***