Skip to content

Commit fea0a96

Browse files
authored
Merge pull request #5465 from janw-me/master
2 parents b9e30a0 + 0472cf4 commit fea0a96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

php/utils.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
* We try to be smart and only replace the constants when they are not within quotes.
3030
* Regular expressions being stateless, this is probably not 100% correct for edge cases.
3131
*
32-
* @see https://regex101.com/r/9hXp5d/4/
32+
* @see https://regex101.com/r/9hXp5d/11
33+
* @see https://stackoverflow.com/a/171499/933065
3334
*
3435
* @var string
3536
*/
36-
const FILE_DIR_PATTERN = '/(?>\'[^\']*?\')|(?>"[^"]*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)/m';
37+
const FILE_DIR_PATTERN = '%(?>#.*?$)|(?>//.*?$)|(?>/\*.*?\*/)|(?>\'(?:(?=(\\\\?))\1.)*?\')|(?>"(?:(?=(\\\\?))\2.)*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)%ms';
3738

3839
function inside_phar() {
3940
return 0 === strpos( WP_CLI_ROOT, PHAR_STREAM_PREFIX );

0 commit comments

Comments
 (0)