Ticket #17 (closed defect: fixed)

Opened 3 years ago

Last modified 6 months ago

Code Coverage Reports & instead of &

Reported by: norman@sefiroth.de Assigned to: mrook
Priority: minor Milestone: 2.2.0
Component: Version: 2.2.0RC1
Keywords: Code Coverage, & Cc:

Description

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

Norman

Attachments

Change History

04/10/06 07:46:56 changed by norman@sefiroth.de

  • 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?

BTW:

Changing line 190 in CoverageReportTask.php

form

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

to

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

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

Thanks,

Norman

04/12/06 15:16:58 changed 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;".

04/13/06 07:08:36 changed by norman@sefiroth.de

Sorry mrook,

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

http://opendocumentphp.sourceforge.net/poc/coverage/0.4.6/OpenDocument/AutomaticStyles.html

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;

but

$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

04/13/06 07:57:44 changed 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?

Thanks,

Michiel

04/13/06 09:41:38 changed by norman@sefiroth.de

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

04/13/06 12:40:42 changed by mrook

  • status changed from assigned to closed.
  • resolution set to fixed.

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

Thanks! Michiel

04/13/06 12:50:39 changed by anonymous

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


Add/Change #17 (Code Coverage Reports &amp; instead of &)




Action