From 99ed5ffcc99a2ba962a275fa255b6958bc83cc25 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 1 Nov 2013 16:56:42 -0500 Subject: [PATCH] Don't break UTF-8 strings on obfuscate. --- HtmlBuilder.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/HtmlBuilder.php b/HtmlBuilder.php index d6699cf..52f1614 100755 --- a/HtmlBuilder.php +++ b/HtmlBuilder.php @@ -127,7 +127,7 @@ class HtmlBuilder { return 'attributes($attributes).'>'.$this->entities($title).''; } - + /** * Generate a HTTPS HTML link. * @@ -200,7 +200,7 @@ class HtmlBuilder { /** * Generate a HTML link to an email address. - * + * * @param string $email * @param string $title * @param array $attributes @@ -209,14 +209,14 @@ class HtmlBuilder { public function mailto($email, $title = null, $attributes = array()) { $email = $this->email($email); - + $title = $title ?: $email; - + $email = $this->obfuscate('mailto:') . $email; - + return 'attributes($attributes).'>'.$this->entities($title).''; } - + /** * Obfuscate an e-mail address to prevent spam-bots from sniffing it. * @@ -368,6 +368,8 @@ class HtmlBuilder { foreach (str_split($value) as $letter) { + if (ord($letter) > 128) return $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.