summaryrefslogtreecommitdiff
path: root/inc/parser/renderer.php
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2015-07-25 23:13:18 +0100
committerAnika Henke <anika@selfthinker.org>2015-07-25 23:13:18 +0100
commit0bfc8d5a03c495c3436780901fe59341faee4d9e (patch)
tree5fe7a6e2e087880647a748b1fbd53ca66aafd943 /inc/parser/renderer.php
parentcf2c8e759bf06596f9492d090f4dd8dbb76a178c (diff)
parent6cb9974651aef2a41b48fcb922cc6baa18a0660f (diff)
downloadrpg-0bfc8d5a03c495c3436780901fe59341faee4d9e.tar.gz
rpg-0bfc8d5a03c495c3436780901fe59341faee4d9e.tar.bz2
Merge remote-tracking branch 'origin/master' into styler
Conflicts: lib/exe/css.php
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}&amp;btnI=lucky';
+ $url = 'https://www.google.com/search?q={URL}&amp;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);