/usr/share/php/tests/Horde_Text_Filter/Horde/Text/Filter/Text2htmlTest.php is in php-horde-text-filter 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | <?php
/**
* Horde_Text_Filter_Text2html tests.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Text_Filter
* @subpackage UnitTests
*/
class Horde_Text_Filter_Text2htmlTest extends PHPUnit_Framework_TestCase
{
public function testText2html()
{
$tests = array(
'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.2.horde.org/'
);
$levels = array(
Horde_Text_Filter_Text2html::PASSTHRU => array(
'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.2.horde.org/',
),
Horde_Text_Filter_Text2html::SYNTAX => array(
'<a href="http://www.horde.org/foo/" target="_blank">http://www.horde.org/foo/</a>',
'<a href="https://jan:secret@www.horde.org/foo/" target="_blank">https://jan:secret@www.horde.org/foo/</a>',
'mailto:<a href="mailto:jan@example.com">jan@example.com</a>',
'<a href="svn+ssh://jan@svn.example.com/path/" target="_blank">svn+ssh://jan@svn.example.com/path/</a>',
'<tag>foo</tag>',
'<<a href="http://css.maxdesign.com.au/listamatic/" target="_blank">http://css.maxdesign.com.au/listamatic/</a>>',
'<a href="http://www.horde.org/?foo=bar&baz=qux" target="_blank">http://www.horde.org/?foo=bar&baz=qux</a>',
'<a href="http://www" target="_blank">http://www</a>.<alert>.horde.org/',
'<a href="http://www.&#x32;.horde.org/" target="_blank">http://www.&#x32;.horde.org/</a>'
),
Horde_Text_Filter_Text2html::MICRO => array(
'<a href="http://www.horde.org/foo/" target="_blank">http://www.horde.org/foo/</a>',
'<a href="https://jan:secret@www.horde.org/foo/" target="_blank">https://jan:secret@www.horde.org/foo/</a>',
'mailto:<a href="mailto:jan@example.com">jan@example.com</a>',
'<a href="svn+ssh://jan@svn.example.com/path/" target="_blank">svn+ssh://jan@svn.example.com/path/</a>',
'<tag>foo</tag>',
'<<a href="http://css.maxdesign.com.au/listamatic/" target="_blank">http://css.maxdesign.com.au/listamatic/</a>>',
'<a href="http://www.horde.org/?foo=bar&baz=qux" target="_blank">http://www.horde.org/?foo=bar&baz=qux</a>',
'<a href="http://www" target="_blank">http://www</a>.<alert>.horde.org/',
'<a href="http://www.&#x32;.horde.org/" target="_blank">http://www.&#x32;.horde.org/</a>'
),
Horde_Text_Filter_Text2html::MICRO_LINKURL => array(
'<a href="http://www.horde.org/foo/" target="_blank">http://www.horde.org/foo/</a>',
'<a href="https://jan:secret@www.horde.org/foo/" target="_blank">https://jan:secret@www.horde.org/foo/</a>',
'mailto:jan@example.com',
'<a href="svn+ssh://jan@svn.example.com/path/" target="_blank">svn+ssh://jan@svn.example.com/path/</a>',
'<tag>foo</tag>',
'<<a href="http://css.maxdesign.com.au/listamatic/" target="_blank">http://css.maxdesign.com.au/listamatic/</a>>',
'<a href="http://www.horde.org/?foo=bar&baz=qux" target="_blank">http://www.horde.org/?foo=bar&baz=qux</a>',
'<a href="http://www" target="_blank">http://www</a>.<alert>.horde.org/',
'<a href="http://www.&#x32;.horde.org/" target="_blank">http://www.&#x32;.horde.org/</a>'
),
Horde_Text_Filter_Text2html::NOHTML => array(
'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/'
),
Horde_Text_Filter_Text2html::NOHTML_NOBREAK => array(
'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/'
)
);
foreach ($levels as $level => $results) {
foreach ($tests as $key => $val) {
$filter = Horde_Text_Filter::filter($val, 'text2html', array(
'parselevel' => $level
));
$this->assertEquals($results[$key], $filter);
}
}
}
public function testBug12253()
{
// ISO-8859-2 encoded data.
$text = base64_decode('a/ZubmVu');
$filter = Horde_Text_Filter::filter($text, 'text2html', array(
'charset' => 'iso-8859-2',
'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
));
$this->assertGreaterThan(0, strlen($filter));
}
}
|