Skip to content

Commit 65ceb1d

Browse files
adrianheinethiemowmde
authored andcommitted
Fix regular expressions in resource loader definitions
1 parent d6ee0ca commit 65ceb1d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
datatype attribute when creating a Property.
99
* Let Property.getDataType return the data type's string identifier instead of
1010
a DataType instance.
11+
* Fix regular expressions in resource loader definitions
1112

1213
### 0.1 (2014-06-18)
1314

resources.mw.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
return call_user_func( function() {
1515
global $wgResourceModules;
1616

17-
preg_match( '+^(.*?)' . DIRECTORY_SEPARATOR . '(vendor|extensions)' . DIRECTORY_SEPARATOR . '(.*)$+', __DIR__, $remoteExtPathParts );
17+
preg_match(
18+
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
19+
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
20+
__DIR__,
21+
$remoteExtPathParts
22+
);
23+
1824
$moduleTemplate = array(
1925
'localBasePath' => __DIR__,
2026
'remoteExtPath' => '../' . $remoteExtPathParts[2] . DIRECTORY_SEPARATOR . $remoteExtPathParts[3],

resources.test.mw.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
global $wgHooks;
44

55
$wgHooks['ResourceLoaderTestModules'][] = function( array &$testModules, \ResourceLoader &$resourceLoader ) {
6-
preg_match( '+^(.*?)' . DIRECTORY_SEPARATOR . '(vendor|extensions)' . DIRECTORY_SEPARATOR . '(.*)$+', __DIR__, $remoteExtPathParts );
6+
preg_match(
7+
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
8+
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
9+
__DIR__,
10+
$remoteExtPathParts
11+
);
12+
713
$moduleTemplate = array(
814
'localBasePath' => __DIR__,
915
'remoteExtPath' => '../' . $remoteExtPathParts[2] . DIRECTORY_SEPARATOR . $remoteExtPathParts[3],

0 commit comments

Comments
 (0)