diff --git a/inc/parser/handler.php b/inc/parser/handler.php index f36a4f151b5614661a11e770a6f26eef076206d8..fbe10d431e0b3e69469171a7d3546a2aaf5bc517 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 7e122bffcecb02117a4a10d7e083a11fc2691f94..687ae5170cd8bbda8e6fec452cd79147a0724a4c 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 b85aa911efff140a8b30ab68d87319aee75dfb31..d85d042507e529bf70bcf717770f84427ec2545d 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); } /** diff --git a/inc/parserutils.php b/inc/parserutils.php index e190a0af7b3499172b4ebb98f2f4fc9e4cfeb89f..f8bec37c1eeac956e47f54a120aa4a2c2c9f68dd 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -198,7 +198,7 @@ function p_get_instructions($text){ $Parser->addMode('rss',new Doku_Parser_Mode_RSS()); $Parser->addMode('media',new Doku_Parser_Mode_Media()); $Parser->addMode('externallink',new Doku_Parser_Mode_ExternalLink()); - $Parser->addMode('email',new Doku_Parser_Mode_Email()); + $Parser->addMode('emaillink',new Doku_Parser_Mode_EmailLink()); $Parser->addMode('windowssharelink',new Doku_Parser_Mode_WindowsShareLink()); //$Parser->addMode('filelink',new Doku_Parser_Mode_FileLink()); //FIXME ??? $Parser->addMode('eol',new Doku_Parser_Mode_Eol());