From: Michael M Slusarz Date: Mon, 30 Nov 2009 18:09:31 +0000 (-0700) Subject: doc, spacing, trim output X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0f1c8c6a003b5aef7c300f52fa02784e87f8f1ff;p=horde.git doc, spacing, trim output --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php index 7d6d484a7..ca1333d3c 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -4,9 +4,9 @@ * * Parameters: *
- * charset -- The charset to use for html_entity_decode() calls.
- * width   -- The wrapping width.
- * wrap    -- Whether to wrap the text or not.
+ * charset - (string) The charset to use for html_entity_decode() calls.
+ * width - (integer) The wrapping width.
+ * wrap - (boolean) Whether to wrap the text or not.
  * 
* * Copyright 2003-2004 Jon Abernathy @@ -190,7 +190,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter self::$linkList; } - return $text; + return trim($text); } /** @@ -244,17 +244,21 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter if ($num < 128) { return chr($num); } + if ($num < 2048) { return chr(($num >> 6) + 192) . chr(($num & 63) + 128); } + if ($num < 65536) { return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); } + if ($num < 2097152) { return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); } + return ''; } @@ -276,20 +280,24 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter if ($link == strip_tags($display)) { return $display; } + $parsed_link = parse_url($link); $parsed_display = parse_url(strip_tags(preg_replace('/^<|>$/', '', $display))); + if (isset($parsed_link['path'])) { $parsed_link['path'] = trim($parsed_link['path'], '/'); if (!strlen($parsed_link['path'])) { unset($parsed_link['path']); } } + if (isset($parsed_display['path'])) { $parsed_display['path'] = trim($parsed_display['path'], '/'); if (!strlen($parsed_display['path'])) { unset($parsed_display['path']); } } + if (((!isset($parsed_link['host']) && !isset($parsed_display['host'])) || (isset($parsed_link['host']) && @@ -305,6 +313,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter self::$linkCount++; self::$linkList .= '[' . self::$linkCount . "] $link\n"; + return $display . '[' . self::$linkCount . ']'; }