mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00: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>
|
<body>
|
||||||
<a class="inline" href="#anchor">InlineLink</a>
|
<a class="inline" href="#anchor">InlineLink</a>
|
||||||
$InsertedLink
|
$InsertedLink
|
||||||
|
<svg><use xlink:href="#sprite"></use></svg>
|
||||||
<body>
|
<body>
|
||||||
</html>');
|
</html>');
|
||||||
$tmpl = new SSViewer($tmplFile);
|
$tmpl = new SSViewer($tmplFile);
|
||||||
@ -1111,7 +1112,12 @@ after')
|
|||||||
'<a class="inline" href="' . $base . '#anchor">InlineLink</a>',
|
'<a class="inline" href="' . $base . '#anchor">InlineLink</a>',
|
||||||
$result
|
$result
|
||||||
);
|
);
|
||||||
|
$this->assertContains(
|
||||||
|
'<svg><use xlink:href="#sprite"></use></svg>',
|
||||||
|
$result,
|
||||||
|
'SSTemplateParser should only rewrite anchor hrefs'
|
||||||
|
);
|
||||||
|
|
||||||
unlink($tmplFile);
|
unlink($tmplFile);
|
||||||
|
|
||||||
Config::inst()->update('SSViewer', 'rewrite_hash_links', $orig);
|
Config::inst()->update('SSViewer', 'rewrite_hash_links', $orig);
|
||||||
@ -1130,6 +1136,7 @@ after')
|
|||||||
<body>
|
<body>
|
||||||
<a class="inline" href="#anchor">InlineLink</a>
|
<a class="inline" href="#anchor">InlineLink</a>
|
||||||
$InsertedLink
|
$InsertedLink
|
||||||
|
<svg><use xlink:href="#sprite"></use></svg>
|
||||||
<body>
|
<body>
|
||||||
</html>');
|
</html>');
|
||||||
$tmpl = new SSViewer($tmplFile);
|
$tmpl = new SSViewer($tmplFile);
|
||||||
@ -1145,6 +1152,11 @@ after')
|
|||||||
// '<a class="inline" href="<?php echo str_replace(',
|
// '<a class="inline" href="<?php echo str_replace(',
|
||||||
// $result
|
// $result
|
||||||
// );
|
// );
|
||||||
|
$this->assertContains(
|
||||||
|
'<svg><use xlink:href="#sprite"></use></svg>',
|
||||||
|
$result,
|
||||||
|
'SSTemplateParser should only rewrite anchor hrefs'
|
||||||
|
);
|
||||||
|
|
||||||
unlink($tmplFile);
|
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
|
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this
|
||||||
// non-dynamically calculated
|
// non-dynamically calculated
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
'/href\s*\=\s*\"\#/',
|
'/(<a[^>]+href *= *)"#/i',
|
||||||
'href="\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
'\\1"\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||||
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
||||||
\'#',
|
\'#',
|
||||||
$text
|
$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
|
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this
|
||||||
// non-dynamically calculated
|
// non-dynamically calculated
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
'/href\s*\=\s*\"\#/',
|
'/(<a[^>]+href *= *)"#/i',
|
||||||
'href="\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
'\\1"\' . (Config::inst()->get(\'SSViewer\', \'rewrite_hash_links\') ?' .
|
||||||
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
' strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") .
|
||||||
\'#',
|
\'#',
|
||||||
$text
|
$text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user