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

From: Date: Tue, 15 Jun 2021 17:43:48 +0000
Subject: Bug #80313 [Com]: String containing comment interpretted as comment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234420@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
 Comment by:         ds9201388 at gmail 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:

Request the SEND_SMS permission.

  <uses-permission android:name="android.permission.SEND_SMS" />
Write your own code for sending SMS using the SmsManager.
Explain to your users https://vbucksinfo.com/ why your gallery
app needs access to services that can cost money, and why they have to grant this permission to use
your app.


Previous Comments:
------------------------------------------------------------------------
[2020-11-04 10:55:46] 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>

------------------------------------------------------------------------
[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


Thread (5 messages)

« previous php.bugs (#234420) next »