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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 02:01:33 2025 UTC