Fixing a bug in the call of a static method. Cleaning up code.

This commit is contained in:
Taylor Otwell committed 2013-04-19 20:26:38 -05:00
1 parent d62c15f8d3
commit 0457d838af
1 file changed
+32 -34
+32 -34
View File
@@ -225,40 +225,7 @@ class HtmlBuilder {
*/
public function email($email)
{
return str_replace('@', '@', static::obfuscate($email));
}
/**
* Obfuscate a string to prevent spam-bots from sniffing it.
*
* @param string $value
* @return string
*/
protected function obfuscate($value)
{
$safe = '';
foreach (str_split($value) as $letter)
{
// To properly obfuscate the value, we will randomly convert each
// letter to its entity or hexadecimal representation, keeping a
// bot from sniffing the randomly obfuscated letters.
switch (rand(1, 3))
{
case 1:
$safe .= '&#'.ord($letter).';';
break;
case 2:
$safe .= '&#x'.dechex(ord($letter)).';';
break;
case 3:
$safe .= $letter;
}
}
return $safe;
return str_replace('@', '@', $this->obfuscate($email));
}
/**
@@ -389,6 +356,37 @@ class HtmlBuilder {
if ( ! is_null($value)) return $key.'="'.e($value).'"';
}
/**
* Obfuscate a string to prevent spam-bots from sniffing it.
*
* @param string $value
* @return string
*/
protected function obfuscate($value)
{
$safe = '';
foreach (str_split($value) as $letter)
{
// To properly obfuscate the value, we will randomly convert each letter to
// its entity or hexadecimal representation, keeping a bot from sniffing
// the randomly obfuscated letters out of the string on the responses.
switch (rand(1, 3))
{
case 1:
$safe .= '&#'.ord($letter).';'; break;
case 2:
$safe .= '&#x'.dechex(ord($letter)).';'; break;
case 3:
$safe .= $letter;
}
}
return $safe;
}
/**
* Dynamically handle calls to the html class.
*