BUGFIX: Module resource regex does not allow ports

This commit is contained in:
Aaron Carlino 2017-07-05 11:55:26 +12:00
parent 64005bff91
commit c836a2e2d2
2 changed files with 12 additions and 1 deletions

View File

@ -643,7 +643,7 @@ class Requirements_Backend
protected function parseModuleResourceReference($file) protected function parseModuleResourceReference($file)
{ {
// String of the form vendor/package:resource. Excludes "http://bla" as that's an absolute URL // String of the form vendor/package:resource. Excludes "http://bla" as that's an absolute URL
if (preg_match('#([^ ]*/[^ ]*) *: *([^ ]*)#', $file, $matches)) { if (preg_match('#([^\/\/][^ /]*\/[^ /]*) *: *([^ ]*)#', $file, $matches)) {
list(, $module, $resource) = $matches; list(, $module, $resource) = $matches;
$moduleObj = ModuleLoader::getModule($module); $moduleObj = ModuleLoader::getModule($module);
if (!$moduleObj) { if (!$moduleObj) {

View File

@ -45,9 +45,11 @@ class RequirementsTest extends SapphireTest
$backend->javascript('http://www.mydomain.com/test.js'); $backend->javascript('http://www.mydomain.com/test.js');
$backend->javascript('https://www.mysecuredomain.com/test.js'); $backend->javascript('https://www.mysecuredomain.com/test.js');
$backend->javascript('//scheme-relative.example.com/test.js'); $backend->javascript('//scheme-relative.example.com/test.js');
$backend->javascript('http://www.mydomain.com:3000/test.js');
$backend->css('http://www.mydomain.com/test.css'); $backend->css('http://www.mydomain.com/test.css');
$backend->css('https://www.mysecuredomain.com/test.css'); $backend->css('https://www.mysecuredomain.com/test.css');
$backend->css('//scheme-relative.example.com/test.css'); $backend->css('//scheme-relative.example.com/test.css');
$backend->css('http://www.mydomain.com:3000/test.css');
$html = $backend->includeInHTML(self::$html_template); $html = $backend->includeInHTML(self::$html_template);
@ -63,6 +65,10 @@ class RequirementsTest extends SapphireTest
(strpos($html, '//scheme-relative.example.com/test.js') !== false), (strpos($html, '//scheme-relative.example.com/test.js') !== false),
'Load external scheme-relative javascript URL' 'Load external scheme-relative javascript URL'
); );
$this->assertTrue(
(strpos($html, 'http://www.mydomain.com:3000/test.js') !== false),
'Load external with port'
);
$this->assertTrue( $this->assertTrue(
(strpos($html, 'http://www.mydomain.com/test.css') !== false), (strpos($html, 'http://www.mydomain.com/test.css') !== false),
'Load external CSS URL' 'Load external CSS URL'
@ -75,6 +81,11 @@ class RequirementsTest extends SapphireTest
(strpos($html, '//scheme-relative.example.com/test.css') !== false), (strpos($html, '//scheme-relative.example.com/test.css') !== false),
'Load scheme-relative CSS URL' 'Load scheme-relative CSS URL'
); );
$this->assertTrue(
(strpos($html, 'http://www.mydomain.com:3000/test.css') !== false),
'Load external with port'
);
} }
/** /**