Bug #80313 [Opn->Nab]: String containing comment interpretted as comment

From: Date: Wed, 04 Nov 2020 09:13:00 +0000
Subject: Bug #80313 [Opn->Nab]: String containing comment interpretted as comment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230099@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80313&edit=1

 ID:                 80313
 Updated by:         requinix@php.net
 Reported by:        jab_creations at yahoo dot com
 Summary:            String containing comment interpretted as comment
-Status:             Open
+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:

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 */.


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#230099) next »