diff options
author | xue <> | 2006-04-11 14:03:06 +0000 |
---|---|---|
committer | xue <> | 2006-04-11 14:03:06 +0000 |
commit | 293fd30c134997b28836ca879a99bd933ec7cbe3 (patch) | |
tree | 7686b9066d0c38a01e316f3d3b734c6aa235b8c1 /framework/Web | |
parent | 5f4f9760225b4070d86c0e2e9f80b33999c17584 (diff) |
Merge from 3.0 branch till 892.
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/THttpUtility.php | 18 |
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('<'=>'<','>'=>'>','"'=>'"e;');
+ private static $_decodeTable=array('<'=>'<','>'=>'>','"e;'=>'"');
/**
* 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);
}
}
|