From: Michael M Slusarz Date: Wed, 10 Jun 2009 07:31:07 +0000 (-0600) Subject: Import Text_Filter from CVS HEAD X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a4821dba3cebdd907a36635ce22b9569ce35e32b;p=horde.git Import Text_Filter from CVS HEAD --- diff --git a/framework/Mime/lib/Horde/Mime/Mail.php b/framework/Mime/lib/Horde/Mime/Mail.php index 4bae1dc96..2c3974492 100644 --- a/framework/Mime/lib/Horde/Mime/Mail.php +++ b/framework/Mime/lib/Horde/Mime/Mail.php @@ -224,8 +224,7 @@ class Horde_Mime_Mail $this->_htmlBody->setCharset($charset); $this->_htmlBody->setContents($body); if ($alternative) { - require_once 'Horde/Text/Filter.php'; - $this->setBody(Text_Filter::filter($body, 'html2text', array('wrap' => false), $charset)); + $this->setBody(Horde_Text_Filter::filter($body, 'html2text', array('wrap' => false), $charset)); } } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php index e8c55f7a0..e033235c5 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php @@ -171,8 +171,7 @@ class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Driver $text = preg_replace('/^ (.*) $/s', '\1', $text); // Make URLs clickable. - require_once 'Horde/Text/Filter.php'; - $text = Text_Filter::filter($text, 'linkurls', array('callback' => 'Horde::externalUrl')); + $text = Horde_Text_Filter::filter($text, 'linkurls', array('callback' => 'Horde::externalUrl')); /* Wordwrap -- note this could impact on our above RFC compliance *IF* * we honored nofill tags (which we don't yet). */ diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Html.php b/framework/Mime/lib/Horde/Mime/Viewer/Html.php index 5d4111cb4..bbe1e0eec 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Html.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Html.php @@ -108,15 +108,15 @@ class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver } } - require_once 'Horde/Text/Filter.php'; $strip_style_attributes = (($browser->isBrowser('mozilla') && $browser->getMajor() == 4) || $browser->isBrowser('msie')); $strip_styles = $inline || $strip_style_attributes; - $data = Text_Filter::filter($data, 'xss', - array('body_only' => $inline, - 'strip_styles' => $strip_styles, - 'strip_style_attributes' => $strip_style_attributes)); + $data = Horde_Text_Filter::filter($data, 'xss', array( + 'body_only' => $inline, + 'strip_styles' => $strip_styles, + 'strip_style_attributes' => $strip_style_attributes + )); /* Check for phishing exploits. */ if ($this->getConfigParam('phishing_check')) { diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Plain.php b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php index cb1e70c35..7d767b31d 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Plain.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php @@ -42,10 +42,9 @@ class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Driver $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); } - require_once 'Horde/Text/Filter.php'; return array( $this->_mimepart->getMimeId() => array( - 'data' => '' . Text_Filter::filter($text, 'text2html', array('parselevel' => TEXT_HTML_MICRO, 'charset' => $charset, 'class' => null)) . '', + 'data' => '' . Horde_Text_Filter::filter($text, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'charset' => $charset, 'class' => null)) . '', 'status' => array(), 'type' => 'text/html; charset=' . $charset ) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php index 57df4bc34..39bc61c43 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php @@ -82,10 +82,9 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver } } - require_once 'Horde/Text/Filter.php'; return array( $this->_mimepart->getMimeId() => array( - 'data' => empty($header_output) ? '' : ('
' . Text_Filter::filter(implode("
\n", $header_output), 'emails') . '
'), + 'data' => empty($header_output) ? '' : ('
' . Horde_Text_Filter::filter(implode("
\n", $header_output), 'emails') . '
'), 'status' => array(), 'type' => 'text/html; charset=' . NLS::getCharset() ) diff --git a/framework/Text_Filter/lib/Horde/Text/Filter.php b/framework/Text_Filter/lib/Horde/Text/Filter.php new file mode 100644 index 000000000..b43eff229 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter.php @@ -0,0 +1,141 @@ + + * @author Jan Schneider + * @package Horde_Text_Filter + */ +class Horde_Text_Filter +{ + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array(); + + /** + * Attempts to return a concrete instance based on $driver. + * + * @param mixed $driver The type of concrete subclass to return. + * This is based on the filter driver ($driver). The + * code is dynamically included. If $driver is an + * array, then we will look in $driver[0] for the + * subclass implementation named $driver[1].php. + * @param array $params A hash containing any additional configuration + * parameters a subclass might need. + * + * @return Text_Filter The newly created concrete instance. + * @throws Horde_Exception + */ + static public function factory($driver, $params = array()) + { + if (is_array($driver)) { + list($app, $driv_name) = $driver; + $driver = basename($driv_name); + } else { + $driver = basename($driver); + } + + $class = (empty($app) ? 'Horde' : $app) . '_Text_Filter_' . ucfirst($driver); + if (class_exists($class)) { + return new $class($params); + } + + throw new Horde_Exception('Class definition of ' . $class . ' not found.'); + } + + /** + * Constructor. + * + * @param array $params Any parameters that the filter instance needs. + */ + public function __construct($params = array()) + { + $this->_params = array_merge($this->_params, $params); + } + + /** + * Applies a set of patterns to a block of text. + * + * @param string $text The text to filter. + * @param array $patterns The array of patterns to filter with. + * + * @return string The transformed text. + */ + public function filter($text, $filters = array(), $params = array()) + { + if (!is_array($filters)) { + $filters = array($filters); + $params = array($params); + } + + foreach ($filters as $num => $filter) { + try { + $filterOb = self::factory($filter, isset($params[$num]) ? $params[$num] : array()); + } catch (Horde_Exception $e) { + return $e->getMessage(); + } + $patterns = $filterOb->getPatterns(); + + /* Pre-processing. */ + $text = $filterOb->preProcess($text); + + /* str_replace() simple patterns. */ + if (isset($patterns['replace'])) { + $text = str_replace(array_keys($patterns['replace']), array_values($patterns['replace']), $text); + } + + /* preg_replace complex patterns. */ + if (isset($patterns['regexp'])) { + $text = preg_replace(array_keys($patterns['regexp']), array_values($patterns['regexp']), $text); + } + + /* Post-processing. */ + $text = $filterOb->postProcess($text); + } + + return $text; + } + + /** + * Executes any code necessaray before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + return $text; + } + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + return array(); + } + + /** + * Executes any code necessaray after applying the filter patterns. + * + * @param string $text The text after the filtering. + * + * @return string The modified text. + */ + public function postProcess($text) + { + return $text; + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Bbcode.php b/framework/Text_Filter/lib/Horde/Text/Filter/Bbcode.php new file mode 100644 index 000000000..b1b19c8b5 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Bbcode.php @@ -0,0 +1,145 @@ + + * entities -- If true before replacing bbcode with HTML tags, any HTML + * entities will be replaced. + * + * + * Supported bbcode: + *
+ *     [b]Bold Text[/b]
+ *     [i]Italics Text[/i]
+ *     [u]Underlined Text[/u]
+ *     [quote]Quoted Text[/quote]
+ *     [center]Centered Text[/center]
+ *
+ *     List of items
+ *     [list]
+ *     [*] Item one
+ *     [*] Item two
+ *     [/list]
+ *
+ *     Numbered list
+ *     [numlist]
+ *     [*] Item one
+ *     [*] Item two
+ *     [/numlist]
+ *
+ *     [url]http://www.horde.org[/url] -> Link to the address using the
+ *         address itself for the text.  You can specify the protocol: http or
+ *         https and the port.
+ *     [url]www.horde.org[/url] -> Link to the address using the address
+ *         itself for the text.  You can specify the port.  The protocol is by
+ *         default http.
+ *     [url=http://www.horde.org]Link to Horde[/url] -> Link to the address
+ *         using "Link to Horde" for the text.  You can specify the protocol:
+ *         http or https and the port.
+ *     [url=www.horde.org]Link to Horde[/url] -> Link to the address using
+ *         "Link to Horde" for the text.  You can specify the port.  The
+ *         protocol is by default http
+ *     [email]cpedrinaci@yahoo.es[/email] -> sets a mailto link.
+ *     [email=cpedrinaci@yahoo.es]Mail to Carlos[/email] -> Sets a mailto link
+ *         and the text is "Mail to Carlos".
+ * 
+ * + * Copyright 2003-2009 The Horde Project (http://www.horde.org/) + * + * Email validation based on Chuck Hagenbuch's + * Mail_RFC822::isValidInetAddress(). + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Carlos Pedrinaci + * @package Horde_Text_Filter + */ +class Horde_Text_Filter_Bbcode extends Horde_Text_Filter +{ + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array( + 'entities' => false + ); + + /** + * Executes any code necessary before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + if ($this->_params['entities']) { + $text = @htmlspecialchars($text); + } + + return $text; + } + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + $replace = array( + '[i]' => '', '[/i]' => '', + '[u]' => '', '[/u]' => '', + '[b]' => '', '[/b]' => '', + '[s]' => '', '[/s]' => '', + '[sub]' => '', '[/sub]' => '', + '[sup]' => '', '[/sup]' => '', + '[center]' => '
', '[/center]' => '
', + '[quote]' => '
', '[/quote]' => '
', + '[list]' => '
    ', '[/list]' => '
', + '[numlist]' => '
    ', '[/numlist]' => '
', + '[*]' => '
  • '); + + /* When checking URLs we validate part of them, but it is up + * to the user to write them correctly (in particular the + * query string). Concerning mails we use the regular + * expression in Mail_RFC822's isValidInetAddress() function, + * slightly modified. */ + $regexp = array( + "#\[url\]((http|https)://([a-zA-Z\d][\w-]*)(\.[a-zA-Z\d][\w-]*)+(:(\d+))?(/([^<>]+))*)\[/url\]#U" => + Horde::link("$1", "$1") . "$1", + + "#\[url\=((http|https)://([a-zA-Z\d][\w-]*)(\.[a-zA-Z\d][\w-]*)+(:(\d+))?(/([^<>]+))*)\]([^<>]+)\[/url\]#U" => + Horde::link("$1", "$1") . "$9", + + "#\[url\](([a-zA-Z\d][\w-]*)(\.[a-zA-Z\d][\w-]*)+(:(\d+))?(/([^<>]+))*)\[/url\]#U" => + Horde::link("http://$1", "http://$1") . "$1", + + "#\[url\=(([a-zA-Z\d][\w-]*)(\.[a-zA-Z\d][\w-]*)+(:(\d+))?(/([^<>]+))*)\]([^<>]+)\[/url\]#U" => + Horde::link("http://$1", "http://$1") . "$8", + + "#\[email\](([*+!.&\#$|\'\\%\/0-9a-zA-Z^_`{}=?~:-]+)@(([0-9a-zA-Z-]+\.)+[0-9a-zA-Z]{2,4}))\[/email\]#U" => + Horde::link("mailto:$1", "mailto:$1") . "$1", + + "#\[email\=(([*+!.&\#$|\'\\%\/0-9a-zA-Z^_`{}=?~:-]+)@(([0-9a-zA-Z-]+\.)+[0-9a-zA-Z]{2,4}))\]([^<>]+)\[/email\]#U" => + Horde::link("mailto:$1", "mailto:$1") . "$5", + + "#\[img\](.*)\[/img\]#U" => + "\"$1\"", + + "#\[img\=(.*)\](.*)\[/img\]#U" => + "\"$2\"", + + "#\[color\=(.*)\](.*)\[/color\]#U" => + "$2" + + ); + + return array('replace' => $replace, 'regexp' => $regexp); + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Cleanascii.php b/framework/Text_Filter/lib/Horde/Text/Filter/Cleanascii.php new file mode 100644 index 000000000..313dc3be6 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Cleanascii.php @@ -0,0 +1,81 @@ + + * @package Horde_Text + */ +class Horde_Text_Filter_Cleanascii extends Horde_Text_Filter +{ + /** + * Executes any code necessary before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + if (preg_match('/|([^#]*)#.*/', $text, $regs)) { + $text = $regs[1]; + + if (!empty($text)) { + $text = $text . "\n"; + } + } + + return $text; + } + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + /* Remove control characters. */ + $regexp = array('/[\x00-\x1f]+/' => ''); + + /* The '’' entry may look wrong, depending on your editor, + * but it's not - that's not really a single quote. */ + $replace = array( + chr(150) => '-', + chr(167) => '*', + '·' => '*', + '…' => '...', + '‘' => "'", + '’' => "'", + '“' => '"', + '”' => '"', + '•' => '*', + '–' => '-', + '—' => '-', + 'Ÿ' => '*', + '' => '.', + '' => '*', + '' => '*', + '' => '-', + '' => '-', + '' => '*', + '' => '*', + '' => '*', + '•' => '*', + '►' => '>', + ); + + return array('regexp' => $regexp, 'replace' => $replace); + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Dimsignature.php b/framework/Text_Filter/lib/Horde/Text/Filter/Dimsignature.php new file mode 100644 index 000000000..07ee6c3e7 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Dimsignature.php @@ -0,0 +1,36 @@ + + * @package Horde_Text + */ +class Horde_Text_Filter_Dimsignature extends Horde_Text_Filter +{ + /** + * Executes any code necessary after applying the filter patterns. + * + * @param string $text The text after the filtering. + * + * @return string The modified text. + */ + public function postProcess($text) + { + $parts = preg_split('|(\n--\s*(?:
    )?\r?\n)|', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $num_parts = count($parts); + if ($num_parts > 2) { + return implode('', array_slice($parts, 0, -2)) + . '' . $parts[$num_parts - 2] + . $parts[$num_parts - 1] . ''; + } + + return $text; + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Emails.php b/framework/Text_Filter/lib/Horde/Text/Filter/Emails.php new file mode 100644 index 000000000..dd14fc165 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Emails.php @@ -0,0 +1,183 @@ + + * always_mailto - (boolean) If true, a mailto: link is generated always. + * Only if no mail/compose registry API method exists + * otherwise. + * class - (string) CSS class of the generated tag. Defaults to none. + * encode - (boolean) Whether to escape special HTML characters in the URLs + * and finally "encode" the complete tag so that it can be decoded + * later with the decode() method. This is useful if you want to run + * htmlspecialchars() or similar *after* using this filter. + * + * + * Copyright 2003-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Tyler Colbert + * @author Jan Schneider + * @package Horde_Text + */ +class Horde_Text_Filter_Emails extends Horde_Text_Filter +{ + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array( + 'always_mailto' => false, + 'class' => '', + 'encode' => false + ); + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + $class = empty($this->_params['class']) + ? '' + : ' class="' . $this->_params['class'] . '"'; + + $regexp = <<)? + /eix +EOR; + + if (isset($GLOBALS['registry']) && + is_a($GLOBALS['registry'], 'Registry') && + $GLOBALS['registry']->hasMethod('mail/compose') && + !$this->_params['always_mailto']) { + /* If we have a mail/compose registry method, use it. */ + $replacement = 'Horde_Text_Filter_Emails::callback(\'registry\', \'' + . $this->_params['encode'] . '\', \'' . $class + . '\', \'$1\', \'$2\', \'$3\', \'$4\', \'$5\', \'$7\', \'$8\', \'$9\', \'$10\', \'$11\', \'$13\', \'$14\')'; + } else { + /* Otherwise, generate a standard mailto: and let the browser + * handle it. */ + if ($this->_params['encode']) { + $replacement = <<' . htmlspecialchars('$3$5') . '' + . htmlspecialchars('$4$8') + : htmlspecialchars('$9') . '' . htmlspecialchars('$10$11') . '' +EOP; + $replacement = 'chr(1).chr(1).chr(1).base64_encode(' + . $replacement . ').chr(1).chr(1).chr(1)'; + } else { + $replacement = 'Horde_Text_Filter_Emails::callback(\'link\', \'' + . $this->_params['encode'] . '\', \'' . $class + . '\', \'$1\', \'$2\', \'$3\', \'$4\', \'$5\', \'$7\', \'$8\', \'$9\', \'$10\', \'$11\', \'$13\', \'$14\')'; + } + } + + return array('regexp' => array($regexp => $replacement)); + } + + /** + * TODO + */ + static public function callback($mode, $encode, $class, $bracket1, + $protocol, $email, $closing, $args_long, + $args, $bracket2, $prefix, $email2, + $args_long2, $args2, $closebracket) + { + if ($mode == 'link') { + if ($email2 === '') { + return $bracket1 . $protocol . '' . $email . $args_long . '' . $closing . $bracket2; + } + + return (($prefix == '<') ? '<' : $prefix) . '' . $email2 . $args_long2 . '' . ($closebracket ? '>' : ''); + } + + if (!empty($email2)) { + $args = $args2; + $email = $email2; + $args_long = $args_long2; + } + + parse_str($args, $extra); + $url = $GLOBALS['registry']->call('mail/compose', + array(array('to' => $email), + $extra)); + if (is_a($url, 'PEAR_Error')) { + $url = 'mailto:' . urlencode($email); + } + + $url = str_replace('&', '&', $url); + if (substr($url, 0, 11) == 'javascript:') { + $href = '#'; + $onclick = ' onclick="' . substr($url, 11) . ';return false;"'; + } else { + $href = $url; + $onclick = ''; + } + + if ($encode) { + return chr(1).chr(1).chr(1) + . base64_encode( + htmlspecialchars($bracket1 . $protocol . $prefix) + . '' + . htmlspecialchars($email . $args_long) . '' + . htmlspecialchars($bracket2)) + . chr(1).chr(1).chr(1) . $closing . ($closebracket ? '>' : ''); + } + + return $bracket1 . $protocol . $prefix . '' . htmlspecialchars($email) . $args_long + . '' . $bracket2 . $closing . ($closebracket ? '>' : ''); + } + + /** + * "Decodes" the text formerly encoded by using the "encode" parameter. + * + * @param string $text An encoded text. + * + * @return string The decoded text. + */ + static public function decode($text) + { + return preg_replace('/\01\01\01([\w=+\/]*)\01\01\01/e', 'base64_decode(\'$1\')', $text); + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Emoticons.php b/framework/Text_Filter/lib/Horde/Text/Filter/Emoticons.php new file mode 100644 index 000000000..e33b3c8bf --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Emoticons.php @@ -0,0 +1,148 @@ + + * entities -- If true the html entity versions of the patterns will be used. + * + * + * Copyright 2003-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Marko Djukic + * @package Horde_Text + */ +class Horde_Text_Filter_Emoticons extends Horde_Text_Filter +{ + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array('entities' => false); + + /** + * The icon path. + * + * @var string + */ + static protected $_iconpath; + + /* List complex strings before simpler ones, otherwise for example :(( + * would be matched against :( before :(( is found. */ + static protected $_icons = array( + ':/' => 'frustrated', ':-/' => 'frustrated', + // ':*>' => 'blush', + ':e' => 'disappointed', + '=:)$' => 'mrt', + '#|' => 'hangover', '#-|' => 'hangover', + ':-@' => 'shout', ':@' => 'shout', + ':((' => 'bigfrown', ':C' => 'bigfrown', + ':S' => 'dazed', ':-S' => 'dazed', + 'X@' => 'angry', + 'X(' => 'mad', + // '>:)' => 'devil', '>:-)' => 'devil', + // '>:p' => 'deviltongue', '>:-p' => 'deviltongue', + // '>:p' => 'raspberry', '>:P' => 'raspberry', + // '&)' => 'punk', + // '&p' => 'punktongue', + // '=&)' => 'punkmohawk', + ':]' => 'grin', + '#[' => 'hurt', '#(' => 'hurt', '#-[' => 'hurt', '#-(' => 'hurt', + ':O' => 'embarrassed', ':-O' => 'embarrassed', + ':[' => 'sad', + // '>:@' => 'enraged', + // ':&' => 'annoyed', + '=(' => 'worried', '=-(' => 'worried', + ':|=' => 'vampire', + ':-(' => 'frown', ':(' => 'frown', + ':D' => 'biggrin', ':-D' => 'biggrin', ':d' => 'biggrin', ':-d' => 'biggrin', + '8)' => 'cool', + // In English, 8PM occurs sufficiently often to specifically + // search for and exclude + '8p(? 'cooltongue', // '8Þ' => 'cooltongue', + '8D' => 'coolgrin', + ':p' => 'tongueout', ':P' => 'tongueout', // ':Þ' => 'tongueout', + '?:(' => 'confused', '%-(' => 'confused', + // ':)&' => 'love', + 'O;-)' => 'angelwink', + ';]' => 'winkgrin', + ';p' => 'winktongue', ';P' => 'winktongue', // ';Þ' => 'winktongue', + ':|' => 'indifferent', ':-|' => 'indifferent', + '!|' => 'tired', '!-I' => 'tired', + '|I' => 'asleep', '|-I' => 'asleep', + 'O:)' => 'angel', 'O:-)' => 'angel', + 'O;)' => 'angelwink', + ';-)' => 'wink', ';)' => 'wink', + ':#)' => 'clown', ':o)' => 'clown', + ':)' => 'smile', ':-)' => 'smile', + ); + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + /* Build the patterns. */ + $patterns = array_keys($this->getIcons()); + if ($this->_params['entities']) { + $patterns = array_map('htmlspecialchars', $patterns); + $beg_pattern = '(^|\s|
    | )('; + $end_pattern = ')(?=\s|
    | )'; + } else { + $beg_pattern = '(^|\s)('; + $end_pattern = ')(?=\s)'; + } + $patterns = array_map('preg_quote', $patterns); + + /* Check for a smiley either immediately at the start of a line or + * following a space. Use {} as the preg delimiters as this is not + * found in any smiley. */ + $regexp['{' . $beg_pattern . implode('|', $patterns) . $end_pattern . '}e'] = 'Horde_Text_Filter_Emoticons::getImage(\'$2\', \'$1\', \'' . ($this->_params['entities'] ? '$3' : '') . '\')'; + + return array('regexp' => $regexp); + } + + /** + * Returns the img tag for an emoticon. + * + * @see self::getPatterns() + * + * @param string $icon The emoticon. + * @param string $prefix A html prefix. + * @param string $postfix A html postfix. + * + * @return string HTML code with the image tag and any additional prefix + * or postfix. + */ + static public function getImage($icon, $prefix, $postfix) + { + if (!isset(self::$_iconpath)) { + self::$_iconpath = $GLOBALS['registry']->getImageDir('horde') . '/emoticons'; + } + + return $prefix . Horde::img(self::getIcons($icon) . '.png', $icon, array('align' => 'middle', 'title' => $icon), self::$_iconpath) . $postfix; + } + + /** + * Returns a hash with all emoticons and names or the name of a single + * emoticon. + * + * @param string $icon If set, return the name for that emoticon only. + * + * @return array|string Patterns hash or icon name. + */ + static public function getIcons($icon = null) + { + return is_null($icon) + ? self::$_icons + : (isset(self::$_icons[$icon]) ? self::$_icons[$icon] : null); + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Environment.php b/framework/Text_Filter/lib/Horde/Text/Filter/Environment.php new file mode 100644 index 000000000..da5f2579f --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Environment.php @@ -0,0 +1,30 @@ + + * @package Horde_Text + */ +class Horde_Text_Filter_Environment extends Horde_Text_Filter +{ + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + $regexp = array('/^#.*$\n/m' => '', + '/^([^#]*)#.*$/m' => '$1', + '/%([A-Za-z_]+)%/e' => 'getenv("$1")'); + return array('regexp' => $regexp); + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Highlightquotes.php b/framework/Text_Filter/lib/Horde/Text/Filter/Highlightquotes.php new file mode 100644 index 000000000..a945c742c --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Highlightquotes.php @@ -0,0 +1,234 @@ + + * 'citeblock' -- Display cite blocks? (DEFAULT: true) + * 'cssLevels' -- Number of defined CSS class names. (DEFAULT: 5) + * 'hideBlocks' -- Hide quoted text blocks by default? (DEFAULT: false) + * 'outputJS' -- Add necessary JS files? (DEFAULT: true) + * + * + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Michael Slusarz + * @author Jan Schneider + * @package Horde_Text + */ +class Horde_Text_Filter_Highlightquotes extends Horde_Text_Filter +{ + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array( + 'citeblock' => true, + 'cssLevels' => 5, + 'hideBlocks' => false, + 'outputJS' => true + ); + + /** + * Executes any code necessaray before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + /* Tack a newline onto the beginning of the string so that we + * correctly highlight when the first character in the string is a + * quote character. */ + return "\n$text"; + } + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + /* Remove extra spaces before quoted text as the CSS formatting will + * automatically add a bit of space for us. */ + return ($this->_params['citeblock']) + ? array('regexp' => array("/
    \s*\n\s*
    \s*\n\s*((>\s?)+)/m" => "
    \n\\1")) + : array(); + } + + /** + * Executes any code necessaray after applying the filter patterns. + * + * @param string $text The text after the filtering. + * + * @return string The modified text. + */ + public function postProcess($text) + { + /* Use cite blocks to display the different quoting levels? */ + $cb = $this->_params['citeblock']; + + /* Cite level before parsing the current line. */ + $qlevel = 0; + + /* Other loop variables. */ + $text_out = ''; + $lines = array(); + $tmp = array('level' => 0, 'lines' => array()); + $qcount = 0; + + /* Parse text line by line. */ + foreach (explode("\n", $text) as $line) { + /* Cite level of current line. */ + $clevel = 0; + $matches = array(); + + /* Do we have a citation line? */ + if (preg_match('/^\s*((>\s?)+)/m', $line, $matches)) { + /* Count number of > characters => cite level */ + $clevel = count(preg_split('/>\s?/', $matches[1])) - 1; + } + + if ($cb && isset($matches[1])) { + /* Strip all > characters. */ + $line = substr($line, Horde_String::length($matches[1])); + } + + /* Is this cite level lower than the current level? */ + if ($clevel < $qlevel) { + $lines[] = $tmp; + if ($clevel == 0) { + $text_out .= $this->_process($lines, $qcount); + $lines = array(); + $qcount = 0; + } + $tmp = array('level' => $clevel, 'lines' => array()); + + /* Is this cite level higher than the current level? */ + } elseif ($clevel > $qlevel) { + $lines[] = $tmp; + $tmp = array('level' => $clevel, 'lines' => array()); + } + + $tmp['lines'][] = $line; + $qlevel = $clevel; + + if ($qlevel) { + ++$qcount; + } + } + + $lines[] = $tmp; + $text_out .= $this->_process($lines, $qcount); + + /* Remove the leading newline we added above, if it's still there. */ + return ($text_out[0] == "\n") + ? substr($text_out, 1) + : $text_out; + } + + /** + * TODO + * + * @param array $lines TODO + * @param integer $qcount TODO + * + * @return string TODO + */ + protected function _process($lines, $qcount) + { + $curr = reset($lines); + $out = implode("\n", $this->_removeBr($curr['lines'])); + + if ($qcount > 8) { + if ($this->_params['outputJS']) { + Horde::addScriptFile('prototype.js', 'horde', true); + } + + $out .= (($this->_params['citeblock']) ? '
    ' : '') . + '
    ' . + '_params['outputJS'] ? 'onclick="[ this, this.next(), this.next(1) ].invoke(\'toggle\')" ' : '') . + 'class="widget toggleQuoteShow"' . ($this->_params['hideBlocks'] ? '' : ' style="display:none"') . '>' . htmlspecialchars(sprintf(_("[Show Quoted Text - %d lines]"), $qcount)) . '' . + '_params['outputJS'] ? 'onclick="[ this, this.previous(), this.next() ].invoke(\'toggle\')" ' : "") . + 'class="widget toggleQuoteHide"' . ($this->_params['hideBlocks'] ? ' style="display:none"' : '') . '>' . htmlspecialchars(_("[Hide Quoted Text]")) . ''; + } + + $level = 0; + + next($lines); + while (list(,$curr) = each($lines)) { + if ($level > $curr['level']) { + for ($i = $level; $i > $curr['level']; --$i) { + $out .= $this->_params['citeblock'] ? '
    ' : ''; + } + } else { + for ($i = $level; $i < $curr['level']; ++$i) { + /* Add quote block start tags for each cite level. */ + $out .= ($this->_params['citeblock'] ? '
    _params['cssLevels']) + 1) . '"' . + ((($level == 0) && ($qcount > 8) && $this->_params['hideBlocks']) ? ' style="display:none"' : '') . + '>'; + } + } + + $out .= implode("\n", $this->_removeBr($curr['lines'])); + $level = $curr['level']; + } + + for ($i = $level; $i > 0; --$i) { + $out .= $this->_params['citeblock'] ? '
    ' : ''; + } + + return ($qcount > 8) + ? $out . '' + : $out; + } + + /** + * Remove leading and trailing BR tags. + * + * @param array $lines An array of text. + * + * @return array The array with bare BR tags removed at the beginning and + * end. + */ + protected function _removeBr($lines) + { + /* Remove leading/trailing line breaks. Spacing between quote blocks + * will be handled by div CSS. */ + if (!$this->_params['citeblock']) { + return $lines; + } + + foreach (array_keys($lines) as $i) { + if (!preg_match("/^\s*\s*$/i", $lines[$i])) { + break; + } + unset($lines[$i]); + } + + foreach (array_reverse(array_keys($lines)) as $i) { + if (!preg_match("/^\s*\s*$/i", $lines[$i])) { + break; + } + unset($lines[$i]); + } + + return $lines; + } + +} diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php new file mode 100644 index 000000000..7d6d484a7 --- /dev/null +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -0,0 +1,311 @@ + + * charset -- The charset to use for html_entity_decode() calls. + * width -- The wrapping width. + * wrap -- Whether to wrap the text or not. + * + * + * Copyright 2003-2004 Jon Abernathy + * Original source: http://www.chuggnutt.com/html2text.php + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Jon Abernathy + * @author Jan Schneider + * @package Horde_Text + */ +class Horde_Text_Filter_Html2text extends Horde_Text_Filter +{ + /* TODO */ + static public $linkList; + static public $linkCount; + + /** + * Filter parameters. + * + * @var array + */ + protected $_params = array( + 'charset' => null, + 'width' => 70, + 'wrap' => true + ); + + /** + * Executes any code necessaray before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + if (is_null($this->_params['charset'])) { + $this->_params['charset'] = isset($GLOBALS['_HORDE_STRING_CHARSET']) ? $GLOBALS['_HORDE_STRING_CHARSET'] : 'ISO-8859-1'; + } + + self::$linkList = ''; + self::$linkCount = 0; + + return trim($text); + } + + /** + * Returns a hash with replace patterns. + * + * @return array Patterns hash. + */ + public function getPatterns() + { + $regexp = array( + // Non-legal carriage return. + '/\r/' => '', + + // Leading and trailing whitespace. + '/^\s*(.*?)\s*$/m' => '\1', + + // Normalize
    . + '/]*>([^\n]*)\n/i' => "
    \\1", + + // Newlines and tabs. + '/[\n\t]+/' => ' ', + + // |is'] = '<' . $this->_params['replace'] . '_script />'; + + /* Get all tags that might cause trouble - , , + * , etc. Meta refreshes and iframes, too. */ + $malicious = array( + '/<([^>a-z]*)' . + '(?:s|�*83;?|�*53;?|�*115;?|�*73;?)\s*' . + '(?:c|�*67;?|�*43;?|�*99;?|�*63;?)\s*' . + '(?:r|�*82;?|�*52;?|�*114;?|�*72;?)\s*' . + '(?:i|�*73;?|�*49;?|�*105;?|�*69;?)\s*' . + '(?:p|�*80;?|�*50;?|�*112;?|�*70;?)\s*' . + '(?:t|�*84;?|�*54;?|�*116;?|�*74;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:m|�*77;?|�*4d;?|�*109;?|�*6d;?)\s*' . + '(?:b|�*66;?|�*42;?|�*98;?|�*62;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:d|�*68;?|�*44;?|�*100;?|�*64;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:x|�*88;?|�*58;?|�*120;?|�*78;?)\s*' . + '(?:m|�*77;?|�*4d;?|�*109;?|�*6d;?)\s*' . + '(?:l|�*76;?|�*4c;?|�*108;?|�*6c;?)(\s*)/i', + + '/<([^>a-z]*)\?([^>a-z]*)' . + '(?:i|�*73;?|�*49;?|�*105;?|�*69;?)\s*' . + '(?:m|�*77;?|�*4d;?|�*109;?|�*6d;?)\s*' . + '(?:p|�*80;?|�*50;?|�*112;?|�*70;?)\s*' . + '(?:o|�*79;?|�*4f;?|�*111;?|�*6f;?)\s*' . + '(?:r|�*82;?|�*52;?|�*114;?|�*72;?)\s*' . + '(?:t|�*84;?|�*54;?|�*116;?|�*74;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:m|�*77;?|�*4d;?|�*109;?|�*6d;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:t|�*84;?|�*54;?|�*116;?|�*74;?)\s*' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:j|�*74;?|�*4a;?|�*106;?|�*6a;?)\s*' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)\s*' . + '(?:v|�*86;?|�*56;?|�*118;?|�*76;?)\s*' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:o|�*79;?|�*4f;?|�*111;?|�*6f;?)\s*' . + '(?:b|�*66;?|�*42;?|�*98;?|�*62;?)\s*' . + '(?:j|�*74;?|�*4a;?|�*106;?|�*6a;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:c|�*67;?|�*43;?|�*99;?|�*63;?)\s*' . + '(?:t|�*84;?|�*54;?|�*116;?|�*74;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)\s*' . + '(?:p|�*80;?|�*50;?|�*112;?|�*70;?)\s*' . + '(?:p|�*80;?|�*50;?|�*112;?|�*70;?)\s*' . + '(?:l|�*76;?|�*4c;?|�*108;?|�*6c;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:t|�*84;?|�*54;?|�*116;?|�*74;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:l|�*76;?|�*4c;?|�*108;?|�*6c;?)\s*' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)\s*' . + '(?:y|�*89;?|�*59;?|�*121;?|�*79;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)\s*' . + '(?:r|�*82;?|�*52;?|�*114;?|�*72;?)(\s*)/i', + + '/<([^>a-z]*)' . + '(?:i|�*73;?|�*49;?|�*105;?|�*69;?)?\s*' . + '(?:f|�*70;?|�*46;?|�*102;?|�*66;?)\s*' . + '(?:r|�*82;?|�*52;?|�*114;?|�*72;?)\s*' . + '(?:a|�*65;?|�*41;?|�*97;?|�*61;?)\s*' . + '(?:m|�*77;?|�*4d;?|�*109;?|�*6d;?)\s*' . + '(?:e|�*69;?|�*45;?|�*101;?|�*65;?)(\s*)/i'); + + foreach ($malicious as $pattern) { + $patterns[$pattern] = '<$1' . $this->_params['replace'] . '_tag$2'; + } + + /* Comment out style/link tags. */ + if ($this->_params['strip_styles']) { + if ($this->_params['strip_style_attributes']) { + $patterns['/(\s+|([\'"]))style\s*=/i'] = '$2 ' . $this->_params['replace'] . '='; + } + $patterns['|]*>(?:\s*<\!--)*|i'] = '\s*)*|i'] = '-->'; + $patterns['|(]*>)|i'] = ''; + + /* We primarily strip out tags due to styling concerns. + * There is a security issue with HREF tags, but the 'javascript' + * search/replace code sufficiently filters these strings. */ + $patterns['|(]*>)|i'] = ''; + } + + /* A few other matches. */ + $patterns['|<([^>]*)&{.*}([^>]*)>|'] = '<\1&{;}\2>'; + $patterns['|<([^>]*)mocha:([^>]*)>|i'] = '<\1' . $this->_params['replace'] . ':\2>'; + $patterns['/<(([^>]*)|(style[^>]*>[^<]*))binding:((?(3)[^<]*<\/style)[^>]*)>/i'] = '<\1' . $this->_params['replace'] . ':\4>'; + + return array('regexp' => $patterns); + } + + /** + * Executes any code necessary before applying the filter patterns. + * + * @param string $text The text before the filtering. + * + * @return string The modified text. + */ + public function preProcess($text) + { + // As of PHP 5.2, backtrack limits have been set to an unreasonably + // low number. The body check will often times trigger backtrack + // errors so up the backtrack limit if we are doing this match. + if ($this->_params['body_only'] && ini_get('pcre.backtrack_limit')) { + ini_set('pcre.backtrack_limit', 5000000); + } + + return $text; + } + + /** + * Executes any code necessary after applying the filter patterns. + * + * @param string $text The text after the filtering. + * + * @return string The modified text. + */ + public function postProcess($text) + { + ini_restore('pcre.backtrack_limit'); + return $text; + } + +} diff --git a/framework/Text_Filter/package.xml b/framework/Text_Filter/package.xml new file mode 100644 index 000000000..bee5156b6 --- /dev/null +++ b/framework/Text_Filter/package.xml @@ -0,0 +1,254 @@ + + + Text_Filter + pear.horde.org + Horde Text Filter API + The Horde_Text_Filter:: class provides common methods for + fitering and converting text. + + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + + Jan Schneider + jan + jan@horde.org + yes + + + Michael Slusarz + slusarz + slusarz@horde.org + yes + + 2009-06-10 + + 0.1.0 + 0.1.0 + + + beta + beta + + LGPL + * Initial Horde 4 package. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.5.4 + + + Util + pear.horde.org + + + + + gettext + + + + + + + + + + + + + + + + + + + + + + + + + + 2006-05-08 + + + 0.0.2 + 0.0.2 + + + alpha + alpha + + LGPL + * Don't strip BASE tags when 'strip_styles' is false. + * Added ability to link <test@example.com> e-mail addresses in plain text. + * Removed dependency on external javascript file when toggling quoted lines. + * Converted to package.xml 2.0 for pear.horde.org + * Allow the bad words filter to leave the first character of a matching word and replace the rest with '*' (duck@obala.net). + * Improved efficiency of the linkurls filter when searching long lines + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2004-10-12 + LGPL + Initial release as a PEAR package + + + + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/emails.phpt b/framework/Text_Filter/test/Horde/Text/Filter/emails.phpt new file mode 100644 index 000000000..4bdc2ae2a --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/emails.phpt @@ -0,0 +1,39 @@ +--TEST-- +Horde_Text_Filter_Email tests +--FILE-- + test. +Inline angle brackets (HTML) <test@example.com> test. +Inline angle brackets with mailto <mailto:test@example.com> test. +Inline with parameters test@example.com?subject=A%20subject&body=The%20message%20body test. +Inline protocol with parameters mailto:test@example.com?subject=A%20subject&body=The%20message%20body test. +test@example.com in front test. +At end test of test@example.com +Don't link http://test@www.horde.org/ test. +Real world example: mailto:pmx-auto-approve%2b27f0e770e2d85bf9bd8fea61f9dedbff@example.com?subject=Release%20message%20from%20quarantine&body=%5b%23ptn6Pw-1%5d +EOT; + +echo Horde_Text_Filter::filter($emails, 'emails', array('always_mailto' => true, 'class' => 'pagelink')); + +?> +--EXPECT-- +Inline address test@example.com test. +Inline protocol mailto: test@example.com test with whitespace. +Inline Outlook [mailto:test@example.com] test. +Inline angle brackets <test@example.com> test. +Inline angle brackets (HTML) <test@example.com> test. +Inline angle brackets with mailto <mailto:test@example.com> test. +Inline with parameters test@example.com?subject=A%20subject&body=The%20message%20body test. +Inline protocol with parameters mailto:test@example.com?subject=A%20subject&body=The%20message%20body test. +test@example.com in front test. +At end test of test@example.com +Don't link http://test@www.horde.org/ test. +Real world example: mailto:pmx-auto-approve%2b27f0e770e2d85bf9bd8fea61f9dedbff@example.com?subject=Release%20message%20from%20quarantine&body=%5b%23ptn6Pw-1%5d diff --git a/framework/Text_Filter/test/Horde/Text/Filter/environment.phpt b/framework/Text_Filter/test/Horde/Text/Filter/environment.phpt new file mode 100644 index 000000000..f11615385 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/environment.phpt @@ -0,0 +1,30 @@ +--TEST-- +Horde_Text_Filter_Environment tests +--FILE-- + +--EXPECT-- +Simple line +Inline bar variable +bar at start +at end bar +Variable bar with +Simple line diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/html2text.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/html2text.html new file mode 100644 index 000000000..e20e5075e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/html2text.html @@ -0,0 +1,163 @@ +

    Inline Formatting

    + + Some text with leading and trailing whitespace + + + + + + + + + + + + + + + + + + + + + + + + + + +
    emphasis textemphasis text
    strong textstrong text
    italic textitalic text
    bold textbold text
    emphasis and strongemphasis and strong
    underline textunderline text
    + +
    + + +

    Links

    +Horde Homepage
    +Test User
    +Some inline link.
    +http://www.example.com
    + +
    + + +

    Headings

    +

    You can make various levels of heading by putting equals-signs before and +after the text (all on its own line):

    + +

    level 3 heading

    +

    level 4 heading

    + +
    level 5 heading
    +
    level 6 heading
    + +
    + + +

    Bullet Lists

    +

    You can create bullet lists by starting a paragraph with one or more +asterisks.

    + +
      +
    • Bullet one
        +
      • Sub-bullet
      • +
    • +
    + +

    Numbered Lists

    +

    Similarly, you can create numbered lists by starting a paragraph with one +or more hashes.

    + +
      +
    1. Numero uno
    2. +
    3. Number two
        +
      1. Sub-item
      2. +
    4. + +
    + +

    Mixing Bullet and Number List Items

    +

    You can mix and match bullet and number lists:

    + +
      +
    1. Number one
        +
      • Bullet
      • +
      • Bullet
      • +
    2. +
    3. Number two
        +
      • Bullet
      • +
      • Bullet
          +
        • Sub-bullet
            +
          1. Sub-sub-number
          2. +
          3. Sub-sub-number
          4. +
        • +
      • +
    4. +
    5. Number three
        +
      • Bullet
      • +
      • Bullet
      • +
    6. +
    + + +

    Block quoting

    +
    +Horde Homepage
    +Some inline link.
    +
    + +Line inbetween. + +
    +

    Heading inside quoting

    +

    This is a paragraph inside a block quoting. The result should be several +lines prefixed with the > character.

    +
    + + +

    Special Characters

    + +ä +é +© +™ + +

    Zitat von John Doe <john.doe@example.com>:

    +
    +
    +

    Hallo lieber John,

    +

    +

    Blah, blah.'

    +

    +

    +
    +
    +

    +

    --
    +Some signature
    http://www.example.com

    + +

    Zitat von Jane Doe <jane.doe@example.com>:

    +
    +Jan Schneider a écrit : + +
    Zitat von Jane Doe +<jane.doe@example.com>: +

    +
    Hi, +

    +I prepare the last "horde-webmail-1.2" for production level but I have +few questions: +
    +- is there a way to disable "external_display_cal" in kronolith, I +don't want seeing birthdays calendars (turba) and task list (nag) +

    +They aren't displayed by default, or do you mean you don't want them to +appear in the top right calendar panel? +
    +
    +Yes I don't want them to appear in the top right calendar panel but I +want user can create their external_cal
    +

    +

    Jan.

    +--
    +Do you need professional PHP or Horde consulting?
    http://horde.org/consulting/

    diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/style_xss01.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/style_xss01.html new file mode 100644 index 000000000..7876e7a3e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/style_xss01.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/text2html.txt b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/text2html.txt new file mode 100644 index 000000000..550e1e7ed --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/text2html.txt @@ -0,0 +1,9 @@ +http://www.horde.org/foo/ +https://jan:secret@www.horde.org/foo/ +mailto:jan@example.com +svn+ssh://jan@svn.example.com/path/ +foo + +http://www.horde.org/?foo=bar&baz=qux +http://www..horde.org/ +http://www.2.horde.org/ diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss01.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss01.html new file mode 100644 index 000000000..e5b2f4b50 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss01.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss02.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss02.html new file mode 100644 index 000000000..268771bc3 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss02.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss03.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss03.html new file mode 100644 index 000000000..16a49c704 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss03.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss04.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss04.html new file mode 100644 index 000000000..d4b96e6f0 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss04.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss05.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss05.html new file mode 100644 index 000000000..0188bcd04 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss05.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss06.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss06.html new file mode 100644 index 000000000..e6fa46523 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss06.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss07.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss07.html new file mode 100644 index 000000000..8db558400 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss07.html @@ -0,0 +1 @@ +"> diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss08.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss08.html new file mode 100644 index 000000000..8127962ed --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss08.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss09.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss09.html new file mode 100644 index 000000000..28fe4b46e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss09.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss10.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss10.html new file mode 100644 index 000000000..cec7c2232 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss10.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss100.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss100.html new file mode 100644 index 000000000..e93f96942 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss100.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss11.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss11.html new file mode 100644 index 000000000..08f172b49 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss11.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss12.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss12.html new file mode 100644 index 000000000..ef55d25a5 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss12.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss13.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss13.html new file mode 100644 index 000000000..30ba58e45 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss13.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss14.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss14.html new file mode 100644 index 000000000..c6eefd035 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss14.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss15.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss15.html new file mode 100644 index 000000000..df671373d --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss15.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss16.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss16.html new file mode 100644 index 000000000..ccf6dc162 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss16.html @@ -0,0 +1,28 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss17.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss17.html new file mode 100644 index 000000000..88efc5c2e Binary files /dev/null and b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss17.html differ diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss18.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss18.html new file mode 100644 index 000000000..bf09f11f5 Binary files /dev/null and b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss18.html differ diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss19.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss19.html new file mode 100644 index 000000000..c49600be1 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss19.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss20.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss20.html new file mode 100644 index 000000000..50f4d4dc2 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss20.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss21.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss21.html new file mode 100644 index 000000000..6ee2c8155 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss21.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss22.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss22.html new file mode 100644 index 000000000..fedaeda3b --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss22.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss23.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss23.html new file mode 100644 index 000000000..a7a4a6eca --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss23.html @@ -0,0 +1 @@ +< diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss24.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss24.html new file mode 100644 index 000000000..c271ad200 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss24.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss29.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss29.html new file mode 100644 index 000000000..b114c44de --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss29.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss30.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss30.html new file mode 100644 index 000000000..f59e849fb --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss30.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss31.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss31.html new file mode 100644 index 000000000..4b26cf03c --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss31.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss32.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss32.html new file mode 100644 index 000000000..e15a0ef30 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss32.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss33.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss33.html new file mode 100644 index 000000000..c94b3d418 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss33.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss34.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss34.html new file mode 100644 index 000000000..3572594af --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss34.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss35.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss35.html new file mode 100644 index 000000000..7cb3640e0 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss35.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss36.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss36.html new file mode 100644 index 000000000..78b1828f4 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss36.html @@ -0,0 +1 @@ +
    diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss37.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss37.html new file mode 100644 index 000000000..2bebdc5de --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss37.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss38.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss38.html new file mode 100644 index 000000000..60f5311ae --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss38.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss39.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss39.html new file mode 100644 index 000000000..9c0166611 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss39.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss40.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss40.html new file mode 100644 index 000000000..2ff8dd36c --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss40.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss41.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss41.html new file mode 100644 index 000000000..adad3d308 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss41.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss42.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss42.html new file mode 100644 index 000000000..bb88069fb --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss42.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss43.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss43.html new file mode 100644 index 000000000..ba7f8202a --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss43.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss44.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss44.html new file mode 100644 index 000000000..1793ffcb0 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss44.html @@ -0,0 +1 @@ +
    • XSS diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss45.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss45.html new file mode 100644 index 000000000..87a0ea4e5 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss45.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss46.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss46.html new file mode 100644 index 000000000..092cbe76a --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss46.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss47.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss47.html new file mode 100644 index 000000000..a578bd63e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss47.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss48.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss48.html new file mode 100644 index 000000000..fd8671368 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss48.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss49.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss49.html new file mode 100644 index 000000000..c0ffc6bda --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss49.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss50.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss50.html new file mode 100644 index 000000000..9ab79e2de --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss50.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss51.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss51.html new file mode 100644 index 000000000..15dc19e38 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss51.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss52.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss52.html new file mode 100644 index 000000000..933a89094 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss52.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss53.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss53.html new file mode 100644 index 000000000..efeb87cb7 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss53.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss54.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss54.html new file mode 100644 index 000000000..890ea0837 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss54.html @@ -0,0 +1 @@ +
      diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss55.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss55.html new file mode 100644 index 000000000..220aaa924 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss55.html @@ -0,0 +1 @@ +
      diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss56.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss56.html new file mode 100644 index 000000000..25c0bddec --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss56.html @@ -0,0 +1 @@ +
      diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss57.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss57.html new file mode 100644 index 000000000..4b776f18d --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss57.html @@ -0,0 +1 @@ +
      diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss58.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss58.html new file mode 100644 index 000000000..0cecb362c --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss58.html @@ -0,0 +1 @@ +
      diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss59.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss59.html new file mode 100644 index 000000000..9cfcd768f --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss59.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss60.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss60.html new file mode 100644 index 000000000..4e0a95305 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss60.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss61.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss61.html new file mode 100644 index 000000000..85d1cc826 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss61.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss62.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss62.html new file mode 100644 index 000000000..430e2142b --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss62.html @@ -0,0 +1,2 @@ +exp/* diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss63.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss63.html new file mode 100644 index 000000000..78c5e208d --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss63.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss64.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss64.html new file mode 100644 index 000000000..c8b61d153 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss64.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss65.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss65.html new file mode 100644 index 000000000..7e2c6c411 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss65.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss66.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss66.html new file mode 100644 index 000000000..515ddcd63 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss66.html @@ -0,0 +1,3 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss67.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss67.html new file mode 100644 index 000000000..7876e7a3e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss67.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss68.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss68.html new file mode 100644 index 000000000..edb75dd66 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss68.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss69.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss69.html new file mode 100644 index 000000000..5467328b0 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss69.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss70.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss70.html new file mode 100644 index 000000000..63c915958 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss70.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss71.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss71.html new file mode 100644 index 000000000..be76fd375 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss71.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss72.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss72.html new file mode 100644 index 000000000..0cf2fad6e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss72.html @@ -0,0 +1,4 @@ + + + XSS + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss73.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss73.html new file mode 100644 index 000000000..dd29eb80a --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss73.html @@ -0,0 +1,2 @@ +]]> + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss74.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss74.html new file mode 100644 index 000000000..60497e75f --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss74.html @@ -0,0 +1,2 @@ +<IMG SRC="javascript:alert('XSS')"> + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss75.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss75.html new file mode 100644 index 000000000..95687cb66 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss75.html @@ -0,0 +1,2 @@ + + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss76.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss76.html new file mode 100644 index 000000000..28c5baf1e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss76.html @@ -0,0 +1,5 @@ + + + + + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss77.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss77.html new file mode 100644 index 000000000..c50331ca8 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss77.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss80.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss80.html new file mode 100644 index 000000000..c87808145 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss80.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss81.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss81.html new file mode 100644 index 000000000..411984c1c --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss81.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss82.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss82.html new file mode 100644 index 000000000..6c09ee68e --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss82.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss83.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss83.html new file mode 100644 index 000000000..6354cc3db --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss83.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss84.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss84.html new file mode 100644 index 000000000..2ecc9b136 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss84.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss85.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss85.html new file mode 100644 index 000000000..615795675 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss85.html @@ -0,0 +1 @@ +PT SRC="http://ha.ckers.org/a.js"> diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss97.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss97.html new file mode 100644 index 000000000..4f0915e89 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss97.html @@ -0,0 +1 @@ + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss98.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss98.html new file mode 100644 index 000000000..cccbeb452 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss98.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss99.html b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss99.html new file mode 100644 index 000000000..10e268dad --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/fixtures/xss99.html @@ -0,0 +1 @@ + <"" /> diff --git a/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt b/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt new file mode 100644 index 000000000..82abd87db --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt @@ -0,0 +1,153 @@ +--TEST-- +Horde_Text_Filter_Html2text tests +--FILE-- + 'UTF-8')); + +?> +--EXPECT-- +INLINE FORMATTING + +Some text with leading and trailing whitespace + + emphasis text /emphasis text/ + strong text STRONG TEXT + italic text /italic text/ + bold text BOLD TEXT + emphasis and strong /EMPHASIS AND STRONG/ + underline text _underline text_ + +------------------------- + +LINKS + +Horde Homepage[1] +Test User[2] +Some inline link[3]. +http://www.example.com + +------------------------- + +HEADINGS + +You can make various levels of heading by putting equals-signs before +and after the text (all on its own line): + +LEVEL 3 HEADING + +Level 4 Heading + +Level 5 Heading + +Level 6 Heading + +------------------------- + +BULLET LISTS + +You can create bullet lists by starting a paragraph with one or more +asterisks. + + * Bullet one + + * Sub-bullet + +NUMBERED LISTS + +Similarly, you can create numbered lists by starting a paragraph with +one or more hashes. + + * Numero uno + * Number two + + * Sub-item + +MIXING BULLET AND NUMBER LIST ITEMS + +You can mix and match bullet and number lists: + + * Number one + + * Bullet + * Bullet + + * Number two + + * Bullet + * Bullet + + * Sub-bullet + + * Sub-sub-number + * Sub-sub-number + + * Number three + + * Bullet + * Bullet + +BLOCK QUOTING + +> Horde Homepage[4] +> Some inline link[5]. + +Line inbetween. + +> HEADING INSIDE QUOTING +> +> This is a paragraph inside a block quoting. The result should be +> several lines prefixed with the > character. + +SPECIAL CHARACTERS + +ä é © (tm) + +Zitat von John Doe : + +> Hallo lieber John, +> +> Blah, blah.' + +-- +Some signature +http://www.example.com + +Zitat von Jane Doe : + +> Jan Schneider a écrit : +> +> > Zitat von Jane Doe : +> > +> > > Hi, +> > > +> > > I prepare the last "horde-webmail-1.2" for production +> > > level but I have few questions: +> > > - is there a way to disable "external_display_cal" in +> > > kronolith, I don't want seeing birthdays calendars (turba) and +> > task +> > > list (nag) +> > +> > +> > They aren't displayed by default, or do you mean you don't want +> > them to appear in the top right calendar panel? +> +> Yes I don't want them to appear in the top right calendar panel +> but I want user can create their external_cal + +Jan. + +-- +Do you need professional PHP or Horde consulting? +http://horde.org/consulting/ + +Links: +------ +[1] http://www.horde.org +[2] mailto:test@example.com +[3] http://www.horde.org +[4] http://www.horde.org +[5] http://www.horde.org diff --git a/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt b/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt new file mode 100644 index 000000000..6934715dd --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Horde_Text_Filter_Html2text lists test +--FILE-- + +
    • This is a short line.
    • +
    • This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line.
    • +
    • And again a short line.
    • + +EOT; +echo Horde_Text_Filter::filter($html, 'html2text', array('width' => 50)); +echo Horde_Text_Filter::filter($html, 'html2text', array('wrap' => false)); + +?> +--EXPECT-- + * This is a short line. + * This is a long line. This is a long line. +This is a long line. This is a long line. This is +a long line. This is a long line. This is a long +line. This is a long line. This is a long line. +This is a long line. This is a long line. This is +a long line. + * And again a short line. + + + + * This is a short line. + * This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. + * And again a short line. diff --git a/framework/Text_Filter/test/Horde/Text/Filter/html2text3.phpt b/framework/Text_Filter/test/Horde/Text/Filter/html2text3.phpt new file mode 100644 index 000000000..f6c818679 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/html2text3.phpt @@ -0,0 +1,68 @@ +--TEST-- +Horde_Text_Filter_Html2text quoting test +--FILE-- +Zitat von Roberto Maurizzi <roberto.maurizzi@gmail.com>:

      +
      +
      +
      +
      +
      +
      4) In Turba, I can select a VFS driver to use. Currently it is set to
      + +None and turba seems to be working fine. What does Turba use the VFS
      +for?
      +
      +

      +You can attach files to contacts with that.

      +Jan.
      +
      +

      +
      Anything similar for Kronolith, maybe in the new version?
      I've googled a little and only found a discussion in 2004 about having attachment (or links) from VFS in Kronolith.
      +I'd really like to be able to attach all my taxes forms to the day I have to pay them ;-) and more in general all the extra documentation regarding an appointment.

      Ciao,
        Roberto

      +
      +

      Some unquoted line with single ' quotes.

      +

      Jan.

      +--
      +Do you need professional PHP or Horde consulting?
      http://horde.org/consulting/

      +EOT; +echo Horde_Text_Filter::filter($html, 'html2text'); + +?> +--EXPECT-- +Zitat von Roberto Maurizzi : + +> > > > 4) In Turba, I can select a VFS driver to use. Currently it +is +> > set +> > > > to +> > > > None and turba seems to be working fine. What does Turba use +> > the +> > > > VFS +> > > > for? +> > +> > You can attach files to contacts with that. +> > +> > Jan. +> +> Anything similar for Kronolith, maybe in the new version? +> I've googled a little and only found a discussion in 2004 about +> having attachment (or links) from VFS in Kronolith. +> I'd really like to be able to attach all my taxes forms to the day +> I have to pay them ;-) and more in general all the extra +> documentation regarding an appointment. +> +> Ciao, +> Roberto + +Some unquoted line with single ' quotes. + +Jan. + +-- +Do you need professional PHP or Horde consulting? +http://horde.org/consulting/ diff --git a/framework/Text_Filter/test/Horde/Text/Filter/space2html.phpt b/framework/Text_Filter/test/Horde/Text/Filter/space2html.phpt new file mode 100644 index 000000000..27d54a3f9 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/space2html.phpt @@ -0,0 +1,28 @@ +--TEST-- +Horde_Text_Filter_Space2html tests +--FILE-- + false)); + echo "\n"; + echo Horde_Text_Filter::filter($space, 'space2html', array('encode_all' => true)); + echo "\n"; +} + +?> +--EXPECT-- +x x +x x +x  x +x  x +x   x +x   x +x        x +x        x +x                x +x                x diff --git a/framework/Text_Filter/test/Horde/Text/Filter/text2html.phpt b/framework/Text_Filter/test/Horde/Text/Filter/text2html.phpt new file mode 100644 index 000000000..7fb4aff95 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/text2html.phpt @@ -0,0 +1,86 @@ +--TEST-- +Horde_Text_Filter_Text2html tests +--FILE-- + null); +$levels = array(Horde_Text_Filter_Text2html::PASSTHRU, + Horde_Text_Filter_Text2html::SYNTAX, + Horde_Text_Filter_Text2html::MICRO, + Horde_Text_Filter_Text2html::MICRO_LINKURL, + Horde_Text_Filter_Text2html::NOHTML, + Horde_Text_Filter_Text2html::NOHTML_NOBREAK); + +foreach ($levels as $level) { + $params['parselevel'] = $level; + echo Horde_Text_Filter::filter($text, 'text2html', $params); + echo "-------------------------------------------------\n"; +} + +?> +--EXPECT-- +http://www.horde.org/foo/ +https://jan:secret@www.horde.org/foo/ +mailto:jan@example.com +svn+ssh://jan@svn.example.com/path/ +foo + +http://www.horde.org/?foo=bar&baz=qux +http://www..horde.org/ +http://www.2.horde.org/ +------------------------------------------------- +http://www.horde.org/foo/
      +https://jan:secret@www.horde.org/foo/
      +mailto:jan@example.com
      +svn+ssh://jan@svn.example.com/path/
      +<tag>foo</tag>
      +<http://css.maxdesign.com.au/listamatic/>
      +http://www.horde.org/?foo=bar&baz=qux
      +http://www.<alert>.horde.org/
      +http://www.&#x32;.horde.org/
      +------------------------------------------------- +http://www.horde.org/foo/
      +https://jan:secret@www.horde.org/foo/
      +mailto:jan@example.com
      +svn+ssh://jan@svn.example.com/path/
      +<tag>foo</tag>
      +<http://css.maxdesign.com.au/listamatic/>
      +http://www.horde.org/?foo=bar&baz=qux
      +http://www.<alert>.horde.org/
      +http://www.&#x32;.horde.org/
      +------------------------------------------------- +http://www.horde.org/foo/
      +https://jan:secret@www.horde.org/foo/
      +mailto:jan@example.com
      +svn+ssh://jan@svn.example.com/path/
      +<tag>foo</tag>
      +<http://css.maxdesign.com.au/listamatic/>
      +http://www.horde.org/?foo=bar&baz=qux
      +http://www.<alert>.horde.org/
      +http://www.&#x32;.horde.org/
      +------------------------------------------------- +http://www.horde.org/foo/
      +https://jan:secret@www.horde.org/foo/
      +mailto:jan@example.com
      +svn+ssh://jan@svn.example.com/path/
      +<tag>foo</tag>
      +<http://css.maxdesign.com.au/listamatic/>
      +http://www.horde.org/?foo=bar&baz=qux
      +http://www.<alert>.horde.org/
      +http://www.&#x32;.horde.org/
      +------------------------------------------------- +http://www.horde.org/foo/ +https://jan:secret@www.horde.org/foo/ +mailto:jan@example.com +svn+ssh://jan@svn.example.com/path/ +<tag>foo</tag> +<http://css.maxdesign.com.au/listamatic/> +http://www.horde.org/?foo=bar&baz=qux +http://www.<alert>.horde.org/ +http://www.&#x32;.horde.org/ +------------------------------------------------- diff --git a/framework/Text_Filter/test/Horde/Text/Filter/xss.phpt b/framework/Text_Filter/test/Horde/Text/Filter/xss.phpt new file mode 100644 index 000000000..d9f425945 --- /dev/null +++ b/framework/Text_Filter/test/Horde/Text/Filter/xss.phpt @@ -0,0 +1,242 @@ +--TEST-- +Horde_Text_Filter_Xss tests +--FILE-- + false)); +} + +foreach (glob(dirname(__FILE__) . '/fixtures/style_xss*.html') as $file) { + $data = file_get_contents($file); + echo basename($file) . "\n"; + echo Horde_Text_Filter::filter($data, 'xss', array('body_only' => false, 'strip_styles' => false)); +} + +?> +--EXPECT-- +xss01.html + +xss02.html + +xss03.html + +xss04.html + +xss05.html + +xss06.html + +xss07.html +"> +xss08.html + +xss09.html + +xss10.html + +xss100.html + +xss11.html + +xss12.html + +xss13.html + +xss14.html + +xss15.html + +xss16.html + +xss17.html + +xss18.html + +xss19.html + +xss20.html + +xss21.html + +xss22.html + +xss23.html +< +xss24.html + +xss25.html + +xss26.html + +xss29.html + +xss30.html + +xss31.html + +xss32.html + +xss33.html + +xss34.html + +xss35.html + +xss36.html +
      +xss37.html + +xss38.html + +xss39.html + +xss40.html + +xss41.html + +xss42.html + +xss43.html + +xss44.html +
      • XSS +xss45.html + +xss46.html + +xss47.html + +xss48.html + +xss49.html + +xss50.html + +xss51.html + +xss52.html + +xss53.html + +xss54.html +
        +xss55.html +
        +xss56.html +
        +xss57.html +
        +xss58.html +
        +xss59.html + +xss60.html + +xss61.html + +xss62.html +exp/* +xss63.html + +xss64.html + +xss65.html + +xss66.html + +xss67.html + +xss68.html + +xss69.html + +xss70.html + +xss71.html + +xss72.html + + + XSS + +xss73.html +]]> + +xss74.html +<IMG SRC="XSSCleanedalert('XSS')"> + +xss75.html + + +xss76.html + + + + + +xss77.html + +xss78.html + +xss80.html + +xss81.html + +xss82.html + +xss83.html + +xss84.html + +xss85.html +PT SRC="http://ha.ckers.org/a.js"> +xss97.html + +xss98.html + + + + + + + + + + + + +xss99.html + <"" /> +style_xss01.html +