mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix requirements tests
This commit is contained in:
parent
5ffe64f024
commit
f4a77649a4
@ -84,7 +84,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider
|
||||
protected function resolveModuleResource($resource)
|
||||
{
|
||||
// String of the form vendor/package:resource. Excludes "http://bla" as that's an absolute URL
|
||||
if (!preg_match('#(?<module>[^/: ]*/[^/: ]*) *: *(?<resource>[^ ]*)#', $resource, $matches)) {
|
||||
if (!preg_match('#^ *(?<module>[^/: ]+/[^/: ]+) *: *(?<resource>[^ ]*)$#', $resource, $matches)) {
|
||||
return null;
|
||||
}
|
||||
$module = $matches['module'];
|
||||
|
@ -818,20 +818,19 @@ class RequirementsTest extends SapphireTest
|
||||
public function testCommentedOutScriptTagIsIgnored()
|
||||
{
|
||||
/// Disable nonce
|
||||
Injector::inst()->registerService(new SimpleResourceURLGenerator(), ResourceURLGenerator::class);
|
||||
$urlGenerator = new SimpleResourceURLGenerator();
|
||||
Injector::inst()->registerService($urlGenerator, ResourceURLGenerator::class);
|
||||
|
||||
$template = '<html><head></head><body><!--<script>alert("commented out");</script>-->'
|
||||
. '<h1>more content</h1></body></html>';
|
||||
/**
|
||||
* @var Requirements_Backend $backend
|
||||
*/
|
||||
/** @var Requirements_Backend $backend */
|
||||
$backend = Injector::inst()->create(Requirements_Backend::class);
|
||||
$this->setupRequirements($backend);
|
||||
|
||||
$src = $this->getThemeRoot() . '/javascript/RequirementsTest_a.js';
|
||||
$urlSrc = Controller::join_links(Director::baseURL(), $src);
|
||||
$backend->javascript($src);
|
||||
$html = $backend->includeInHTML($template);
|
||||
$urlSrc = $urlGenerator->urlForResource($src);
|
||||
$this->assertEquals(
|
||||
'<html><head></head><body><!--<script>alert("commented out");</script>-->'
|
||||
. '<h1>more content</h1><script type="application/javascript" src="' . $urlSrc
|
||||
|
Loading…
Reference in New Issue
Block a user