php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39783 highlight_string function removes slashes in some cases
Submitted: 2006-12-09 19:37 UTC Modified: 2006-12-10 22:07 UTC
From: tikitiki at mybboard dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.0 OS: Not Applicable
Private report: No CVE-ID: None
 [2006-12-09 19:37 UTC] tikitiki at mybboard dot com
Description:
------------
The slashes (\) gets removed in some instances with invalid php code. In the below reproduce code, the \ gets removed.

The PHP Version isn't applicable, but I had to put 5.2.0 because if I set it to 'Irrelevant' I would get this error 'This category requires you to pick a PHP version.'

I understand that this is far fetched, but it should ATLEAST show up.

Reproduce code:
---------------
<?php
$string = '<?php
$a = 2;
\
$c = 5;
?>';

echo highlight_string($str, true);
?>

Expected result:
----------------
<?php
$a = 2;
\
$c = 5;
?>

Actual result:
--------------
<?php
$a = 2;

$c = 5;
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-10 19:49 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Non-valid characters are ignored by the parser in the instance 
of highlight_string() or file.
 [2006-12-10 22:07 UTC] tikitiki at mybboard dot com
Well, maybe this can be a suggestion then? highlighting should return the full script even if it's malformed. If it's invalid then it shouldn't highlight it, just return it plain
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 17:01:33 2025 UTC