summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-04-18 20:40:11 +0200
committerandi <andi@splitbrain.org>2005-04-18 20:40:11 +0200
commit71352def8211fd38eafe887a9ccd0e5365b34962 (patch)
tree77229b6da810d80dba09a61493cc8a1d87a99e5a /inc/parser
parentbb0a59d46949357f85e4a8deabff585e56b906e5 (diff)
downloadrpg-71352def8211fd38eafe887a9ccd0e5365b34962.tar.gz
rpg-71352def8211fd38eafe887a9ccd0e5365b34962.tar.bz2
fixed email links #259
darcs-hash:20050418184011-9977f-acd3a6583e08ce3732af5ffc4fdc3027e284173e.gz
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/handler.php4
-rw-r--r--inc/parser/parser.php6
-rw-r--r--inc/parser/xhtml.php80
3 files changed, 62 insertions, 28 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index f36a4f151..fbe10d431 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -442,9 +442,9 @@ class Doku_Handler {
return TRUE;
}
- function email($match, $state, $pos) {
+ function emaillink($match, $state, $pos) {
$email = preg_replace(array('/^</','/>$/'),'',$match);
- $this->__addCall('email',array($email, NULL), $pos);
+ $this->__addCall('emaillink',array($email, NULL), $pos);
return TRUE;
}
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 7e122bffc..687ae5170 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -748,11 +748,11 @@ class Doku_Parser_Mode_WindowsShareLink extends Doku_Parser_Mode {
}
//-------------------------------------------------------------------
-class Doku_Parser_Mode_Email extends Doku_Parser_Mode {
+class Doku_Parser_Mode_EmailLink extends Doku_Parser_Mode {
function connectTo($mode) {
//<([\w0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)>
- $this->Lexer->addSpecialPattern("<[\w0-9\-_.]+?@[\w\-]+\.[\w\-\.]+\.*[\w]+>",$mode,'email');
+ $this->Lexer->addSpecialPattern("<[\w0-9\-_.]+?@[\w\-]+\.[\w\-\.]+\.*[\w]+>",$mode,'emaillink');
}
}
@@ -808,7 +808,7 @@ function Doku_Parser_Formatting($remove = '') {
function Doku_Parser_Substition() {
$modes = array(
'acronym','smiley','wordblock','entity','camelcaselink',
- 'internallink','media','externallink','linebreak','email',
+ 'internallink','media','externallink','linebreak','emaillink',
'windowssharelink','filelink','notoc','multiplyentity',
'quotes','rss'
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index b85aa911e..d85d04250 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -512,11 +512,10 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
echo $this->__formatLink($link);
}
- /**
+ /*
* @deprecated not used!!!
* @TODO Correct the CSS class for files? (not windows)
* @TODO Remove hard coded URL to splitbrain.org
- */
function filelink($link, $title = NULL) {
echo '<a';
@@ -538,6 +537,7 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
echo '</a>';
}
+ */
/**
* @TODO Remove hard coded URL to splitbrain.org
@@ -567,31 +567,65 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
echo '</a>';
}
- /**
- * @TODO Protect email address from harvesters
- * @TODO Remove hard coded link to splitbrain.org
- */
- function email($address, $title = NULL) {
- echo '<a';
-
- $title = $this->__getLinkTitle($title, $address, $isImage);
-
+ function emaillink($address, $name = NULL) {
+ global $conf;
+ //simple setup
+ $link = array();
+ $link['target'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['style'] = '';
+ $link['more'] = '';
+
+ //we just test for image here - we need to encode the title our self
+ $this->__getLinkTitle($name, $address, $isImage);
if ( !$isImage ) {
- echo ' class="mail"';
+ $link['class']='mail';
} else {
- echo ' class="media"';
+ $link['class']='media';
+ }
+
+ //shields up
+ if($conf['mailguard']=='visible'){
+ //the mail name gets some visible encoding
+ $address = str_replace('@',' [at] ',$address);
+ $address = str_replace('.',' [dot] ',$address);
+ $address = str_replace('-',' [dash] ',$address);
+
+ $title = $this->__xmlEntities($address);
+ if(empty($name)){
+ $name = $this->__xmlEntities($address);
+ }else{
+ $name = $this->__xmlEntities($name);
+ }
+ }elseif($conf['mailguard']=='hex'){
+ //encode every char to a hex entity
+ for ($x=0; $x < strlen($address); $x++) {
+ $encode .= '&#x' . bin2hex($address[$x]).';';
+ }
+ $address = $encode;
+ $title = $encode;
+ if(empty($name)){
+ $name = $encode;
+ }else{
+ $name = $this->__xmlEntities($name);
+ }
+ }else{
+ //keep address as is
+ $title = $this->__xmlEntities($address);
+ if(empty($name)){
+ $name = $this->__xmlEntities($address);
+ }else{
+ $name = $this->__xmlEntities($name);
+ }
}
- echo ' href="mailto:'.$this->__xmlEntities($address).'"';
-
- echo ' style="background: transparent url(http://wiki.splitbrain.org/images/mail_icon.gif) 0px 1px no-repeat;"';
-
- echo ' onclick="return svchk()" onkeypress="return svchk()">';
-
- echo $title;
-
- echo '</a>';
-
+ $link['url'] = 'mailto:'.$address;
+ $link['name'] = $name;
+ $link['title'] = $title;
+
+ //output formatted
+ echo $this->__formatLink($link);
}
/**