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

From: Date: Wed, 04 Nov 2020 10:55:46 +0000
Subject: Bug #80313 [Nab]: String containing comment interpretted as comment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230101@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: cmb@php.net 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: Could you please read the documentation[1], instead of insulting PHP contributors? | 'C' style comments end at the first */ encountered. [1] <https://www.php.net/manual/en/language.basic-syntax.comments.php> Previous Comments: ------------------------------------------------------------------------ [2020-11-04 10:14:55] jab_creations at yahoo dot com 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#230101) next »