From c836a2e2d288d10e601a29003bcc30a9fb7a3d94 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 5 Jul 2017 11:55:26 +1200 Subject: [PATCH] BUGFIX: Module resource regex does not allow ports --- src/View/Requirements_Backend.php | 2 +- tests/php/View/RequirementsTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/View/Requirements_Backend.php b/src/View/Requirements_Backend.php index 1eafb79e3..d96baf1d5 100644 --- a/src/View/Requirements_Backend.php +++ b/src/View/Requirements_Backend.php @@ -643,7 +643,7 @@ class Requirements_Backend protected function parseModuleResourceReference($file) { // 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; $moduleObj = ModuleLoader::getModule($module); if (!$moduleObj) { diff --git a/tests/php/View/RequirementsTest.php b/tests/php/View/RequirementsTest.php index ebcb71cb4..b42ed8cd7 100644 --- a/tests/php/View/RequirementsTest.php +++ b/tests/php/View/RequirementsTest.php @@ -45,9 +45,11 @@ class RequirementsTest extends SapphireTest $backend->javascript('http://www.mydomain.com/test.js'); $backend->javascript('https://www.mysecuredomain.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('https://www.mysecuredomain.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); @@ -63,6 +65,10 @@ class RequirementsTest extends SapphireTest (strpos($html, '//scheme-relative.example.com/test.js') !== false), 'Load external scheme-relative javascript URL' ); + $this->assertTrue( + (strpos($html, 'http://www.mydomain.com:3000/test.js') !== false), + 'Load external with port' + ); $this->assertTrue( (strpos($html, 'http://www.mydomain.com/test.css') !== false), 'Load external CSS URL' @@ -75,6 +81,11 @@ class RequirementsTest extends SapphireTest (strpos($html, '//scheme-relative.example.com/test.css') !== false), 'Load scheme-relative CSS URL' ); + $this->assertTrue( + (strpos($html, 'http://www.mydomain.com:3000/test.css') !== false), + 'Load external with port' + ); + } /**