Skip to content

Commit bdd6391

Browse files
committed
BUGFIX Respecting SSViewer::$options["rewriteHashlinks"] in SSViewer::process()
1 parent fbe8b7b commit bdd6391

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: core/SSViewer.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,18 @@ public function process($item) {
371371
array_pop(SSViewer::$topLevel);
372372

373373
if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process", " for $template");
374-
374+
375375
// If we have our crazy base tag, then fix # links referencing the current page.
376-
if(strpos($output, '<base') !== false) {
377-
if(SSViewer::$options['rewriteHashlinks'] === 'php') {
378-
$thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
379-
} else {
380-
$thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
376+
if(SSViewer::$options['rewriteHashlinks']) {
377+
if(strpos($output, '<base') !== false) {
378+
if(SSViewer::$options['rewriteHashlinks'] === 'php') {
379+
$thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
380+
} else {
381+
$thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
382+
}
383+
$output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
381384
}
382-
$output = preg_replace('/(<a[^>+]href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
383-
}
385+
}
384386

385387
return $output;
386388
}

0 commit comments

Comments
 (0)