diff options
author | Esther Brunner <esther@kaffeehaus.ch> | 2005-09-02 17:05:27 +0200 |
---|---|---|
committer | Esther Brunner <esther@kaffeehaus.ch> | 2005-09-02 17:05:27 +0200 |
commit | 00a7b5ad8c432fcfb4f394ab300d802a0fe4c35c (patch) | |
tree | ec04a0d2e917ddd25af245c4e75153e1f742d74e /inc | |
parent | da682d4efe15ba703873b4989e0fdb895dd3f140 (diff) | |
download | rpg-00a7b5ad8c432fcfb4f394ab300d802a0fe4c35c.tar.gz rpg-00a7b5ad8c432fcfb4f394ab300d802a0fe4c35c.tar.bz2 |
function obfuscate($email) moved to common.php; used in parser and some plugins
darcs-hash:20050902150527-283c4-dae58038c70aacb000f535e8173fa263ba774f52.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/common.php | 25 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 37 |
2 files changed, 30 insertions, 32 deletions
diff --git a/inc/common.php b/inc/common.php index 5358d5d2e..9d108d77c 100644 --- a/inc/common.php +++ b/inc/common.php @@ -893,6 +893,31 @@ function filesize_h($size, $dec = 1){ } /** + * return an obfuscated email address in line with $conf['mailguard'] setting + * + * @author Harry Fuecks <hfuecks@gmail.com> + * @author Christopher Smith <chris@jalakai.co.uk> + */ +function obfuscate($email) { + global $conf; + + switch ($conf['mailguard']) { + case 'visible' : + $obfuscate = array('@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] '); + return strtr($email, $obfuscate); + + case 'hex' : + $encode = ''; + for ($x=0; $x < strlen($email); $x++) $encode .= '&#x' . bin2hex($email{$x}).';'; + return $encode; + + case 'none' : + default : + return $email; + } +} + +/** * Return DokuWikis version * * @author Andreas Gohr <andi@splitbrain.org> diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index cde1468ac..bba85b7e7 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -672,39 +672,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $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); - } + $address = obfuscate($address); + $title = $address; + if(empty($name)){ + $name = $address; }else{ - //keep address as is - $title = $this->_xmlEntities($address); - if(empty($name)){ - $name = $this->_xmlEntities($address); - }else{ - $name = $this->_xmlEntities($name); - } + $name = $this->_xmlEntities($name); } $link['url'] = 'mailto:'.rawurlencode($address); |