Req #75959 [Com]: Support a function to escape glob metacharacters

From: Date: Wed, 14 Feb 2018 10:27:51 +0000
Subject: Req #75959 [Com]: Support a function to escape glob metacharacters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213948@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75959&edit=1

 ID:                 75959
 Comment by:         maggus dot staab+php at googlemail dot com
 Reported by:        maggus dot staab+php at googlemail dot com
 Summary:            Support a function to escape glob metacharacters
 Status:             Feedback
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        7.0.27
 Block user comment: N
 Private report:     N

 New Comment:

thx for the pointer.

this method does 90% of what I need, but is not exactly what I search.

e.g. glob() supports {} (curly-braces) but those are not escaped with this function.

additionally quotemeta() escapes the ^ character which is not a meta-char in the "glob"
sense.


Previous Comments:
------------------------------------------------------------------------
[2018-02-14 10:01:24] requinix@php.net

http://php.net/manual/en/function.quotemeta.php

------------------------------------------------------------------------
[2018-02-14 09:49:06] maggus dot staab+php at googlemail dot com

Description:
------------
Atm there is no api to escape glob patterns.

this makes glob() useless for cases in which dynamic (maybe even user-supplied contents will be
embedded into the glob pattern).

Test script:
---------------
$glob = 'hallo*lala'; // I want this string to match the literal '*' char 
glob(glob_quote($glob))



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75959&edit=1


Thread (6 messages)

« previous php.bugs (#213948) next »