php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80313 String containing comment interpretted as comment
Submitted: 2020-11-04 09:10 UTC Modified: 2020-11-04 10:55 UTC
From: jab_creations at yahoo dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.12 OS: *nix/Win
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jab_creations at yahoo dot com
New email:
PHP Version: OS:

 

 [2020-11-04 09:10 UTC] 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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-04 09:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2020-11-04 09:13 UTC] 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 10:14 UTC] 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 10:55 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC