Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#17 closed defect (fixed)

Code Coverage Reports & instead of &

Reported by: norman@… Owned by: mrook
Priority: minor Milestone: 2.2.0
Component: Version: 2.2.0RC1
Keywords: Code Coverage, & Cc:


Hi folks,

i saw that in the generated code coverage reports all & will be converted to "& amp ;". That is a good idea, but not if you want an ">" => "&g t ;" => "& amp ;gt;" ...

Thanks in advance


Attachments (0)

Change History (7)

comment:1 Changed 11 years ago by norman@…

  • Priority changed from trivial to minor

As far as I can see by now, the problem is, that a produced coverage.xml file will contain lines like this:

<sourceline coveredcount="0"> * ?&amp;gt;</sourceline> <sourceline coveredcount="0"> * &amp;lt;/code&amp;gt;</sourceline>

but this should better be:

<sourceline coveredcount="0"> * ?&gt;</sourceline> <sourceline coveredcount="0"> * &lt;/code&gt;</sourceline>

Does that give you a hint?


Changing line 190 in CoverageReportTask.php


$lines[$i] = utf8_encode(htmlspecialchars($line));


$lines[$i] = utf8_encode($line);

helped a lot for me. But I am unsure if this is the right way to do it...



comment:2 Changed 11 years ago by mrook

  • Owner set to mrook
  • Status changed from new to assigned

Hi Norman,

I'm not sure what the problem is. The phrase "&gt;" is only transformed to "&amp;gt;" when the phrase is present in a sourcefile. Symbols such as "<" are correctly converted to "&lt;", not "&amp;lt;".

comment:3 Changed 11 years ago by norman@…

Sorry mrook,

that is simply not true for me. Please take a look at this:

This report was generated on a Windows XP System, running PHP 5.1.1 and the PHing SVN Trunk (Release Number 49). And you can bet your life on the fact, the we don't have any line like

$this-&gt;dom = $dom;


$this->dom = $dom;

in our source code. If you need more informations, don't be afraid to ask!

The point is, if you transfer any character of "<",">","&" ... via htmlspecialchars(...) to a &-phrase, you will deliever a new string to utf8_encode which contains a "&gt;" for instands. I don't know if the behaviour of this function has changed , but you can see the results on my system configuration on the link above.

The question is "WHY?": Why do you use both functions in your code?

Yours, Norman

comment:4 Changed 11 years ago by mrook

Hi Norman,

It seems the problem is a little more complex. Apparently DOMDocument->createTextNode() (used in CoverageReportTask::transformSourceFile) escapes output on its own, resulting in &amp;amp; combinations in the coverage.xml temporary file. The XSLT stylesheet *should* have taken care of that, vis-a-vis the three 'disable-output-escaping="yes"' attributes in coverage-frames.xsl.

Apparently, your setup behaves a little different, and does not reduce the &amp;amp; to &amp;. My setup continues to work correctly when I remove the htmlspecialchars() call in CoverageReportTask, and remove the disable-output-escaping attributes in coverage-frames.xsl.

Can you perform this change locally and confirm this works on your setup?



comment:5 Changed 11 years ago by norman@…

Hi Michiel,

if I remove the htmlspecialchars() part in CoverageReportTask everything works fine for me, even if I did not remove the "disable-output-escaping" attribute in the xslt file. (... As I told you before ;-) ... okay, this statement by me was very bad formated in this wiki ...)

Maybe this will fix it for everybody. I think you should give this a try, put it in the repository and mark this as fixed?

Yours, Norman

comment:6 Changed 11 years ago by mrook

  • Resolution set to fixed
  • Status changed from assigned to closed

Norman, the fix has been committed in r54. You can reopen the bug if you continue to have problems.

Thanks! Michiel

comment:7 Changed 11 years ago by anonymous

Hi Michiel! r54 works for me! Thanks a lot, Norman

Add Comment

Modify Ticket

as closed The owner will remain mrook.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.