summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/common.php25
-rw-r--r--inc/parser/xhtml.php37
-rw-r--r--lib/plugins/admin.php23
3 files changed, 31 insertions, 54 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);
diff --git a/lib/plugins/admin.php b/lib/plugins/admin.php
index 9f8d2316e..52ac30647 100644
--- a/lib/plugins/admin.php
+++ b/lib/plugins/admin.php
@@ -127,27 +127,6 @@ class DokuWiki_Admin_Plugin {
function plugin_render($text, $format='xhtml') {
return p_render($format, p_get_instructions($text),$info);
}
-
- // return an obfuscated email address in line with $conf['mailguard'] setting
- // FIXME?? this should really be a common function, used by the renderer as well - no point maintaining two!
- 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;
- }
- }
-
+
}
//Setup VIM: ex: et ts=4 enc=utf-8 :