php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12042 $ can't be escaped when using ereg function
Submitted: 2001-07-11 05:46 UTC Modified: 2001-07-11 05:51 UTC
From: teocl at globalsources dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.0.6 OS: LINUX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: teocl at globalsources dot com
New email:
PHP Version: OS:

 

 [2001-07-11 05:46 UTC] teocl at globalsources dot com
Please see the codes below:
<?

$arrfile = '<?include("$DOCUMENT_ROOT/TEMPLATES/TOP-BANNER.HTM");?>';

if(eregi("<\?include\(\"\$DOCUMENT_ROOT/TEMPLATES/TOP-BANNER\.HTM\"\);\?>",$arrfile))
        print "good\n";
else
        print "bad\n";

?>

The result will return "bad" because the eregi can't find the expression in the $arrfile. If I removed the $, it will return "good". I guess "$" can't be escaped inside the eregi function. Please help.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-11 05:51 UTC] zak@php.net
This is known and expected behavior.  Please review the regex docs more carefully - also search the php-general mailing list archives.

The quick fix is to place 3 backslashes in front of the $.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC