mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3464 from InfinityIo/rewrite_hash_links-SSTemplateParser-fix
Fix over-eager rewrite_hash_links regexp in SSTemplateParser
This commit is contained in:
commit
c57c24eb81
@ -1097,6 +1097,7 @@ after')
|
||||
<body>
|
||||
<a class="inline" href="#anchor">InlineLink</a>
|
||||
$InsertedLink
|
||||
<svg><use xlink:href="#sprite"></use></svg>
|
||||
<body>
|
||||
</html>');
|
||||
$tmpl = new SSViewer($tmplFile);
|
||||
@ -1111,6 +1112,11 @@ after')
|
||||
'<a class="inline" href="' . $base . '#anchor">InlineLink</a>',
|
||||
$result
|
||||
);
|
||||
$this->assertContains(
|
||||
'<svg><use xlink:href="#sprite"></use></svg>',
|
||||
$result,
|
||||
'SSTemplateParser should only rewrite anchor hrefs'
|
||||
);
|
||||
|
||||
unlink($tmplFile);
|
||||
|
||||
@ -1130,6 +1136,7 @@ after')
|
||||
<body>
|
||||
<a class="inline" href="#anchor">InlineLink</a>
|
||||
$InsertedLink
|
||||
<svg><use xlink:href="#sprite"></use></svg>
|
||||
<body>
|
||||
</html>');
|
||||
$tmpl = new SSViewer($tmplFile);
|
||||
@ -1145,6 +1152,11 @@ after')
|
||||
// '<a class="inline" href="<?php echo str_replace(',
|
||||
// $result
|
||||
// );
|
||||
$this->assertContains(
|
||||
'<svg><use xlink:href="#sprite"></use></svg>',
|
||||
$result,
|
||||
'SSTemplateParser should only rewrite anchor hrefs'
|
||||
);
|
||||
|
||||
unlink($tmplFile);
|
||||
|
||||
|
@ -4682,8 +4682,8 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
||||
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this
|
||||
// non-dynamically calculated
|
||||
$text = preg_replace(
|
||||
'/href\s*\=\s*\"\#/',
|
||||
'href="\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||
'/(<a[^>]+href *= *)"#/i',
|
||||
'\\1"\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
||||
\'#',
|
||||
$text
|
||||
|
@ -1136,8 +1136,8 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
||||
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this
|
||||
// non-dynamically calculated
|
||||
$text = preg_replace(
|
||||
'/href\s*\=\s*\"\#/',
|
||||
'href="\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||
'/(<a[^>]+href *= *)"#/i',
|
||||
'\\1"\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
||||
\'#',
|
||||
$text
|
||||
|
Loading…
Reference in New Issue
Block a user