Permalink
Browse files

Fixes for obfuscate_text() when printing emails with numbers in them.

(Patch from Zbigniew Fiedorowicz  - thanks)
  • Loading branch information...
1 parent c1e5e14 commit 2b09e37782ca7933220fda69787e5c83d9d8718c moodler committed Sep 9, 2003
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/weblib.php
View
@@ -1605,13 +1605,20 @@ function obfuscate_text($plaintext) {
$i=0;
$length = strlen($plaintext);
$obfuscated="";
+ $prev_obfuscated = false;
while ($i < $length) {
- if (rand(0,2)) {
+ $c = ord($plaintext{$i});
+ $numerical = ($c >= ord('0')) && ($c <= ord('9'));
+ if ($prev_obfuscated and $numerical ) {
+ $obfuscated.='&#'.ord($plaintext{$i});
+ } else if (rand(0,2)) {
$obfuscated.='&#'.ord($plaintext{$i});
+ $prev_obfuscated = true;
} else {
$obfuscated.=$plaintext{$i};
+ $prev_obfuscated = false;
}
- $i++;
+ $i++;
}
return $obfuscated;
}

0 comments on commit 2b09e37

Please sign in to comment.