aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php4
-rw-r--r--inc/parser/renderer.php11
-rw-r--r--inc/parser/xhtml.php14
3 files changed, 20 insertions, 9 deletions
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
index 2cd23dfaa..8ace02fab 100644
--- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
+++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
@@ -47,9 +47,9 @@ class Test_resolveInterwiki extends DokuWikiTest {
$shortcut = 'nonexisting';
$reference = 'foo @+%/';
$url = $Renderer->_resolveInterWiki($shortcut, $reference);
- $expected = 'https://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky';
- $this->assertEquals($expected, $url);
+ $this->assertEquals('', $url);
+ $this->assertEquals('', $shortcut);
}
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 6a76d4861..fe4eb7908 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -846,9 +846,9 @@ abstract class Doku_Renderer extends Plugin {
if(isset($this->interwiki[$shortcut])) {
$url = $this->interwiki[$shortcut];
} else {
- // Default to Google I'm feeling lucky
- $url = 'https://www.google.com/search?q={URL}&btnI=lucky';
- $shortcut = 'go';
+ // not parsable interwiki outputs '' to make sure string manipluation works
+ $shortcut = '';
+ $url = '';
}
//split into hash and url part
@@ -880,8 +880,9 @@ abstract class Doku_Renderer extends Plugin {
'{PATH}' => $parsed['path'],
'{QUERY}' => $parsed['query'] ,
]);
- } else {
- //default
+ } else if($url != '') {
+ // make sure when no url is defined, we keep it null
+ // default
$url = $url.rawurlencode($reference);
}
//handle as wiki links
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 388e1b7ad..f448d8a25 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1062,11 +1062,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['url'] = $url;
$link['title'] = htmlspecialchars($link['url']);
- //output formatted
+ // output formatted
if($returnonly) {
+ if($url == '') return $link['name'];
return $this->_formatLink($link);
} else {
- $this->doc .= $this->_formatLink($link);
+ if($url == '') $this->doc .= $link['name'];
+ else $this->doc .= $this->_formatLink($link);
}
}
@@ -1248,9 +1250,17 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
list($shortcut, $reference) = explode('>', $src, 2);
$exists = null;
$src = $this->_resolveInterWiki($shortcut, $reference, $exists);
+ if($src == '' && empty($title)){
+ // make sure at least something will be shown in this case
+ $title = $reference;
+ }
}
list($src, $hash) = explode('#', $src, 2);
$noLink = false;
+ if($src == '') {
+ // only output plaintext without link if there is no src
+ $noLink = true;
+ }
$render = ($linking == 'linkonly') ? false : true;
$link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);