summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-04-11 13:48:08 +0000
committerxue <>2006-04-11 13:48:08 +0000
commit48a951a9677bc9a56aacad9a920bdaefa0d4c249 (patch)
tree085aded8741393dcd4e58793df68fae1d5091b59 /framework
parentfe93efeb847a756effd28c6bab97e8a0b21f8646 (diff)
THttpUtility::htmlEncode and htmlDecode now do not deal with &
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/THttpUtility.php18
1 files changed, 7 insertions, 11 deletions
diff --git a/framework/Web/THttpUtility.php b/framework/Web/THttpUtility.php
index 398b3cf3..4cd869b4 100644
--- a/framework/Web/THttpUtility.php
+++ b/framework/Web/THttpUtility.php
@@ -20,17 +20,20 @@
*/
class THttpUtility
{
- private static $_entityTable=null;
+ private static $_encodeTable=array('<'=>'&lt;','>'=>'&gt;','"'=>'&quote;');
+ private static $_decodeTable=array('&lt;'=>'<','&gt;'=>'>','&quote;'=>'"');
/**
* HTML-encodes a string.
- * It is equivalent to {@link htmlspeicalchars} PHP function.
+ * This method translates the following characters to their corresponding
+ * HTML entities: <, >, "
+ * Note, unlike {@link htmlspeicalchars}, & is not translated.
* @param string string to be encoded
* @return string encoded string
*/
public static function htmlEncode($s)
{
- return htmlspecialchars($s);
+ return strtr($s,self::$_encodeTable);
}
/**
@@ -41,14 +44,7 @@ class THttpUtility
*/
public static function htmlDecode($s)
{
- if(!self::$_entityTable)
- self::buildEntityTable();
- return strtr($s,self::$_entityTable);
- }
-
- private static function buildEntityTable()
- {
- self::$_entityTable=array_flip(get_html_translation_table(HTML_ENTITIES,ENT_QUOTES));
+ return strtr($s,self::$_decodeTable);
}
}