summaryrefslogtreecommitdiff
path: root/inc/parser/handler.php
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-04-02 17:48:29 +0200
committerandi <andi@splitbrain.org>2005-04-02 17:48:29 +0200
commit0e1c636e20bd809a1d388e0c6f630b0ecda7086b (patch)
tree5617c75e2a337c861585aaaab7468171d65544a9 /inc/parser/handler.php
parent3fc748361df73d42ec30804c3e0fdfad1fb945e8 (diff)
downloadrpg-0e1c636e20bd809a1d388e0c6f630b0ecda7086b.tar.gz
rpg-0e1c636e20bd809a1d388e0c6f630b0ecda7086b.tar.bz2
new parser: correct pageresolving for internal links
darcs-hash:20050402154829-9977f-f9576f4bafed9cbc9c15f14a41ad3410ec5c5970.gz
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r--inc/parser/handler.php65
1 files changed, 24 insertions, 41 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 78826007e..24f095599 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -341,7 +341,6 @@ class Doku_Handler {
}
/*
- * @TODO What about email?
*/
function internallink($match, $state, $pos) {
// Strip the opening and closing markup
@@ -361,63 +360,47 @@ class Doku_Handler {
$link[1] = $media;
}
}
-
- // Interwiki links
+
+ //decide which kind of link it is
+
if ( preg_match('/^[a-zA-Z]+>{1}[\w()\/\\#~:.?+=&%@!\-;,]+$/u',$link[0]) ) {
+ // Interwiki
$interwiki = preg_split('/>/u',$link[0]);
$this->__addCall(
'interwikilink',
- // UTF8 problem...
array($link[0],$link[1],strtolower($interwiki[0]),$interwiki[1]),
$pos
);
-
- // Link to internal wiki page
- } else if ( preg_match('/^[\w:#]+$/u',$link[0]) ) {
+ }elseif ( preg_match('/\\\\\\\\[\w.:?\-;,]+?\\\\/u',$link[0]) ) {
+ // Windows Share
$this->__addCall(
- 'internallink',
+ 'windowssharelink',
array($link[0],$link[1]),
$pos
);
-
- // Otherwise it's some kind of link to elsewhere
- } else {
-
- // file://
- if ( substr($link[0],0,4) == 'file' ) {
- $this->__addCall(
- 'filelink',
- array($link[0],$link[1]),
- $pos
- );
-
- // Check for Windows shares - potential security issues here?
- // i.e. mode not loaded but still matched here...
- } else if ( preg_match('/\\\\\\\\[\w.:?\-;,]+?\\\\/u',$link[0]) ) {
- $this->__addCall(
- 'windowssharelink',
- array($link[0],$link[1]),
- $pos
+ }elseif ( preg_match('#([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i',$link[0]) ) {
+ // E-Mail
+ $this->__addCall(
+ 'emaillink',
+ array($link[0],$link[1]),
+ $pos
);
-
- // Otherwise it's one of the other valid internal links
- } else {
-
- // Add the scheme as needed...
- $leader = substr($link[0],0,3);
- if ( $leader == 'www' ) {
- $link[0] = 'http://'.$link[0];
- } else if ( $leader == 'ftp' ) {
- $link[0] = 'ftp://'.$link[0];
- }
-
- $this->__addCall(
+ }elseif ( preg_match('#^([a-z0-9]+?)://#i',$link[0]) ) {
+ // external link (accepts all protocols)
+ $this->__addCall(
'externallink',
array($link[0],$link[1]),
$pos
);
- }
+ }else{
+ // internal link
+ $this->__addCall(
+ 'internallink',
+ array($link[0],$link[1]),
+ $pos
+ );
}
+
return TRUE;
}