php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26678 preg_quote doesn't quote forward slashes
Submitted: 2003-12-19 21:58 UTC Modified: 2003-12-20 02:50 UTC
From: gnif at spacevs dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.3.2 OS: Debain
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: gnif at spacevs dot com
New email:
PHP Version: OS:

 

 [2003-12-19 21:58 UTC] gnif at spacevs dot com
Description:
------------
if you use preg_quote to escape a string with forward slashes in it, it doesn't quote them.

Reproduce code:
---------------
$file = 'pages/box/test.php';
echo preg_quote($file);

Expected result:
----------------
pages\/box\/test\.php

Actual result:
--------------
pages/box/test\.php

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-20 02:50 UTC] eru@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

see http://www.php.net/preg_quote 

echo preg_quote($file, \"/\");

 [2012-01-12 11:03 UTC] vovan-ve at yandex dot ru
I'm sorry for necroposting.

Why optional value for $delimiter is NULL? I cannot understand, when I must not escape any delimiter? PCRE always requires delimiter for regexp. I think, there are no such situation, when delimiter can be omitted.

OTOH, preg_quote() must not suppose, that delimiter is slash by default due to there are no defaults to delimiter in regexp. In this case, why $delimiter _is_ optional?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 01:01:30 2024 UTC