Bug #80313 [Nab]: String containing comment interpretted as comment
Edit report at https://bugs.php.net/bug.php?id=80313&edit=1
ID: 80313
User updated by: jab_creations at yahoo dot com
Reported by: jab_creations at yahoo dot com
Summary: String containing comment interpretted as comment
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: *nix/Win
PHP Version: 7.4.12
Block user comment: N
Private report: N
New Comment:
Can we please have someone not on drugs and is also able to actually read and interpret LOGIC open
the bug back up since this effects everyone using PHP as a whole? I'd really appreciate that.
Previous Comments:
------------------------------------------------------------------------
[2020-11-04 09:13:00] requinix@php.net
PHP does not parse the contents of comments. That would defeat the purpose of having a comment in
the first place.
Use end-of-line comments, or do something about the ambiguous */.
------------------------------------------------------------------------
[2020-11-04 09:10:07] jab_creations at yahoo dot com
Description:
------------
When a string contains a closing comment */ PHP fails to interpret it as a string.
My best guess is that the initial parser is looking for comments BEFORE interpreting the structure.
Test script:
---------------
<?php
function xml_cleaner($xml)
{
/*
//Remove CSS Comments (they conflict with checking for proper element nesting):
$xml = str_replace('/*', '__com0', $xml);
$xml = str_replace('*/', 'com1__', $xml);//Bug here.
$xml = preg_replace('/__com0.*?com1__/s', '', $xml);
*/
}
?>
Expected result:
----------------
The parser should ignore comments contained within strings.
Actual result:
--------------
Parse error: syntax error, unexpected 'com1__' (T_STRING) in bug.php on line 7
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80313&edit=1
Thread (5 messages)