php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42346 highlight_string on string of PHP code with unterminated comment: wrong output
Submitted: 2007-08-20 09:29 UTC Modified: 2012-06-05 23:09 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: amazon_shipping_dept at yahoo dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: amazon_shipping_dept at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-08-20 09:29 UTC] amazon_shipping_dept at yahoo dot com
Description:
------------
Running highlight_string() on a string with PHP code and an unterminated comment, produces output that doesn't have the comment. Additionally, when the string is dynamically generated from the file-content of a PHP file using file_get_contents(), a PHP warning about unterminated comments is present in the output.

Reproduce code:
---------------
echo highlight_string('<?php echo "hello"; /*comment*/ /*unterminated comment', true);

Expected result:
----------------
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*comment*/&nbsp;</span><span style="color: #FF8000">/*unterminated comment;</span>
</span>
</code>

Actual result:
--------------
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*comment*/&nbsp;</span>
</span>
</code>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 21:40 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2012-06-05 23:09 UTC] nikic@php.net
Closing as this was already fixed in the meantime. See demo at http://codepad.viper-7.com/1TO1RC.
 [2012-06-05 23:09 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC