summaryrefslogtreecommitdiff
path: root/inc/parser/renderer.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser/renderer.php')
-rw-r--r--inc/parser/renderer.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 35bdd0e3f..d7a3faef8 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -806,18 +806,26 @@ class Doku_Renderer extends DokuWiki_Plugin {
$url = $this->interwiki[$shortcut];
} else {
// Default to Google I'm feeling lucky
- $url = 'http://www.google.com/search?q={URL}&btnI=lucky';
+ $url = 'https://www.google.com/search?q={URL}&btnI=lucky';
$shortcut = 'go';
}
//split into hash and url part
- @list($reference, $hash) = explode('#', $reference, 2);
+ $hash = strrchr($reference, '#');
+ if($hash) {
+ $reference = substr($reference, 0, -strlen($hash));
+ $hash = substr($hash, 1);
+ }
//replace placeholder
if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
//use placeholders
$url = str_replace('{URL}', rawurlencode($reference), $url);
- $url = str_replace('{NAME}', $reference, $url);
+ //wiki names will be cleaned next, otherwise urlencode unsafe chars
+ $url = str_replace('{NAME}', ($url{0} === ':') ? $reference :
+ preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
+ return rawurlencode($match[0]);
+ }, $reference), $url);
$parsed = parse_url($reference);
if(!$parsed['port']) $parsed['port'] = 80;
$url = str_replace('{SCHEME}', $parsed['scheme'], $url);