URLDetectionTest.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. namespace Tests\Unit;
  17. if (!defined('INSTALLDIR')) {
  18. define('INSTALLDIR', dirname(dirname(__DIR__)));
  19. }
  20. if (!defined('GNUSOCIAL')) {
  21. define('GNUSOCIAL', true);
  22. }
  23. if (!defined('STATUSNET')) { // Compatibility
  24. define('STATUSNET', true);
  25. }
  26. use PHPUnit\Framework\TestCase;
  27. require_once INSTALLDIR . '/lib/common.php';
  28. final class URLDetectionTest extends TestCase
  29. {
  30. /**
  31. * @dataProvider provider
  32. * @param $content
  33. * @param $expected
  34. */
  35. public function testProduction($content, $expected)
  36. {
  37. $rendered = common_render_text($content);
  38. // hack!
  39. $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
  40. $this->assertEquals($expected, $rendered);
  41. }
  42. /**
  43. * @dataProvider linkifyProvider
  44. * @param $content
  45. * @param $expected
  46. * @param $config
  47. */
  48. public function testLinkifyProduction($content, $expected, $config)
  49. {
  50. $rendered = common_render_text($content);
  51. // hack!
  52. $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
  53. if (common_config('linkify', $config)) {
  54. $this->assertEquals($expected, $rendered);
  55. } else {
  56. $content = common_remove_unicode_formatting(nl2br(htmlspecialchars($content)));
  57. $this->assertEquals($content, $rendered);
  58. }
  59. }
  60. static public function provider()
  61. {
  62. return array(
  63. array('not a link :: no way',
  64. 'not a link :: no way'),
  65. array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
  66. 'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
  67. array('http://127.0.0.1',
  68. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
  69. array('http://[::1]:99/test.php',
  70. '<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="nofollow external">http://[::1]:99/test.php</a>'),
  71. array('http://::1/test.php',
  72. '<a href="http://::1/test.php" title="http://::1/test.php" rel="nofollow external">http://::1/test.php</a>'),
  73. array('http://::1',
  74. '<a href="http://::1/" title="http://::1/" rel="nofollow external">http://::1</a>'),
  75. array('http://127.0.0.1',
  76. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
  77. array('http://example.com',
  78. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  79. array('http://example.com.',
  80. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  81. array('/var/lib/example.so',
  82. '/var/lib/example.so'),
  83. array('example',
  84. 'example'),
  85. array('mailto:user@example.com',
  86. '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">mailto:user@example.com</a>'),
  87. array('mailto:user@example.com?subject=test',
  88. '<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="nofollow external">mailto:user@example.com?subject=test</a>'),
  89. array('xmpp:user@example.com',
  90. '<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="nofollow external">xmpp:user@example.com</a>'),
  91. array('#example',
  92. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
  93. array('#example.com',
  94. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example.com'))) . '" rel="tag">example.com</a></span>'),
  95. array('#.net',
  96. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
  97. array('http://example',
  98. '<a href="http://example/" title="http://example/" rel="nofollow external">http://example</a>'),
  99. array('http://3xampl3',
  100. '<a href="http://3xampl3/" title="http://3xampl3/" rel="nofollow external">http://3xampl3</a>'),
  101. array('http://example/',
  102. '<a href="http://example/" title="http://example/" rel="nofollow external">http://example/</a>'),
  103. array('http://example/path',
  104. '<a href="http://example/path" title="http://example/path" rel="nofollow external">http://example/path</a>'),
  105. array('http://example.com',
  106. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  107. array('https://example.com',
  108. '<a href="https://example.com/" title="https://example.com/" rel="nofollow external">https://example.com</a>'),
  109. array('ftp://example.com',
  110. '<a href="ftp://example.com/" title="ftp://example.com/" rel="nofollow external">ftp://example.com</a>'),
  111. array('ftps://example.com',
  112. '<a href="ftps://example.com/" title="ftps://example.com/" rel="nofollow external">ftps://example.com</a>'),
  113. array('http://user@example.com',
  114. '<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user@example.com</a>'),
  115. array('http://user:pass@example.com',
  116. '<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user:pass@example.com</a>'),
  117. array('http://example.com:8080',
  118. '<a href="http://example.com:8080/" title="http://example.com:8080/" rel="nofollow external">http://example.com:8080</a>'),
  119. array('http://example.com:8080/test.php',
  120. '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">http://example.com:8080/test.php</a>'),
  121. array('http://www.example.com',
  122. '<a href="http://www.example.com/" title="http://www.example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.example.com</a>'),
  123. array('http://example.com/',
  124. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>'),
  125. array('http://example.com/path',
  126. '<a href="http://example.com/path" title="http://example.com/path" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path</a>'),
  127. array('http://example.com/path.html',
  128. '<a href="http://example.com/path.html" title="http://example.com/path.html" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html</a>'),
  129. array('http://example.com/path.html#fragment',
  130. '<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html#fragment</a>'),
  131. array('http://example.com/path.php?foo=bar&bar=foo',
  132. '<a href="http://example.com/path.php?foo=bar&amp;bar=foo" title="http://example.com/path.php?foo=bar&amp;bar=foo" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.php?foo=bar&amp;bar=foo</a>'),
  133. array('http://example.com.',
  134. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  135. array('http://müllärör.de',
  136. '<a href="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" title="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" rel="nofollow external">http://müllärör.de</a>'),
  137. array('http://ﺱﺲﺷ.com',
  138. '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" title="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="nofollow external">http://ﺱﺲﺷ.com</a>'),
  139. array('http://сделаткартинки.com',
  140. '<a href="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" title="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" rel="nofollow external">http://сделаткартинки.com</a>'),
  141. array('http://tūdaliņ.lv',
  142. '<a href="http://t&#x16B;dali&#x146;.lv/" title="http://t&#x16B;dali&#x146;.lv/" rel="nofollow external">http://tūdaliņ.lv</a>'),
  143. array('http://brændendekærlighed.com',
  144. '<a href="http://br&#xE6;ndendek&#xE6;rlighed.com/" title="http://br&#xE6;ndendek&#xE6;rlighed.com/" rel="nofollow external">http://brændendekærlighed.com</a>'),
  145. array('http://あーるいん.com',
  146. '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" title="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="nofollow external">http://あーるいん.com</a>'),
  147. array('http://예비교사.com',
  148. '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" title="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="nofollow external">http://예비교사.com</a>'),
  149. array('http://example.com.',
  150. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  151. array('http://example.com?',
  152. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>?'),
  153. array('http://example.com!',
  154. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>!'),
  155. array('http://example.com,',
  156. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>,'),
  157. array('http://example.com;',
  158. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>;'),
  159. array('http://example.com:',
  160. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>:'),
  161. array('\'http://example.com\'',
  162. '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>\''),
  163. array('"http://example.com"',
  164. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>&quot;'),
  165. array('"http://example.com/"',
  166. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>&quot;'),
  167. array('http://example.com',
  168. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  169. array('(http://example.com)',
  170. '(<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>)'),
  171. array('[http://example.com]',
  172. '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>]'),
  173. array('<http://example.com>',
  174. '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>&gt;'),
  175. array('http://example.com/path/(foo)/bar',
  176. '<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo)/bar'),
  177. array('http://example.com/path/[foo]/bar',
  178. '<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>[foo]/bar'),
  179. array('http://example.com/path/foo/(bar)',
  180. '<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)'),
  181. //Not a valid url - urls cannot contain unencoded square brackets
  182. array('http://example.com/path/foo/[bar]',
  183. '<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>[bar]'),
  184. array('Hey, check out my cool site http://example.com okay?',
  185. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a> okay?'),
  186. array('What about parens (e.g. http://example.com/path/foo/(bar))?',
  187. 'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar))?'),
  188. array('What about parens (e.g. http://example.com/path/foo/(bar)?',
  189. 'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)?'),
  190. array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
  191. 'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar).)?'),
  192. //Not a valid url - urls cannot contain unencoded commas
  193. array('What about parens (e.g. http://example.com/path/(foo,bar)?',
  194. 'What about parens (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo,bar)?'),
  195. array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
  196. 'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>((((foo)/bar)?'),
  197. array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
  198. 'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo))))/bar)?'),
  199. array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
  200. 'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>((((bar)?'),
  201. array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
  202. 'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar))))?'),
  203. array('file.ext',
  204. 'file.ext'),
  205. array('file.html',
  206. 'file.html'),
  207. array('file.php',
  208. 'file.php'),
  209. // scheme-less HTTP URLs with @ in the path: http://status.net/open-source/issues/2248
  210. array('http://flickr.com/photos/34807140@N05/3838905434',
  211. '<a href="http://www.flickr.com/photos/34807140@N05/3838905434" title="http://www.flickr.com/photos/34807140@N05/3838905434" rel="nofollow external noreferrer" class="attachment thumbnail" id="attachment-XXX">http://flickr.com/photos/34807140@N05/3838905434</a>'),
  212. );
  213. }
  214. static public function linkifyProvider()
  215. {
  216. return array(
  217. //bare ip addresses are no longer supported
  218. array('127.0.0.1',
  219. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1</a>',
  220. 'bare_ipv4'),
  221. array('127.0.0.1:99',
  222. '<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="nofollow external">127.0.0.1:99</a>',
  223. 'bare_ipv4'),
  224. array('127.0.0.1/Name:test.php',
  225. '<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="nofollow external">127.0.0.1/Name:test.php</a>',
  226. 'bare_ipv4'),
  227. array('127.0.0.1/~test',
  228. '<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="nofollow external">127.0.0.1/~test</a>',
  229. 'bare_ipv4'),
  230. array('127.0.0.1/+test',
  231. '<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="nofollow external">127.0.0.1/+test</a>',
  232. 'bare_ipv4'),
  233. array('127.0.0.1/$test',
  234. '<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="nofollow external">127.0.0.1/$test</a>',
  235. 'bare_ipv4'),
  236. array('127.0.0.1/\'test',
  237. '<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="nofollow external">127.0.0.1/\'test</a>',
  238. 'bare_ipv4'),
  239. array('127.0.0.1/"test',
  240. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1/</a>&quot;test',
  241. 'bare_ipv4'),
  242. array('127.0.0.1/test"test',
  243. '<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="nofollow external">127.0.0.1/test</a>&quot;test',
  244. 'bare_ipv4'),
  245. array('127.0.0.1/-test',
  246. '<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="nofollow external">127.0.0.1/-test</a>',
  247. 'bare_ipv4'),
  248. array('127.0.0.1/_test',
  249. '<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="nofollow external">127.0.0.1/_test</a>',
  250. 'bare_ipv4'),
  251. array('127.0.0.1/!test',
  252. '<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="nofollow external">127.0.0.1/!test</a>',
  253. 'bare_ipv4'),
  254. array('127.0.0.1/*test',
  255. '<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="nofollow external">127.0.0.1/*test</a>',
  256. 'bare_ipv4'),
  257. array('127.0.0.1/test%20stuff',
  258. '<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="nofollow external">127.0.0.1/test%20stuff</a>',
  259. 'bare_ipv4'),
  260. array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
  261. '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>',
  262. 'bare_ipv6'),
  263. array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
  264. '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="nofollow external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>',
  265. 'bare_ipv6'),
  266. array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
  267. '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>',
  268. 'bare_ipv6'),
  269. array('example.com',
  270. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
  271. 'bare_domains'),
  272. array('flickr.com/photos/34807140@N05/3838905434',
  273. '<a href="http://flickr.com/photos/34807140@N05/3838905434" title="http://flickr.com/photos/34807140@N05/3838905434" class="attachment thumbnail" id="attachment-XXX" rel="nofollow external">flickr.com/photos/34807140@N05/3838905434</a>',
  274. 'bare_domains'),
  275. array('What about parens (e.g. example.com/path/foo/(bar))?',
  276. 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>)?',
  277. 'bare_domains'),
  278. array('What about parens (e.g. example.com/path/foo/(bar)?',
  279. 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>?',
  280. 'bare_domains'),
  281. array('What about parens (e.g. example.com/path/foo/(bar).)?',
  282. 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>.?',
  283. 'bare_domains'),
  284. array('What about parens (e.g. example.com/path/(foo,bar)?',
  285. 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="nofollow external">example.com/path/(foo,bar)</a>?',
  286. 'bare_domains'),
  287. array('example.com',
  288. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
  289. 'bare_domains'),
  290. array('example.org',
  291. '<a href="http://example.org/" title="http://example.org/" rel="nofollow external">example.org</a>',
  292. 'bare_domains'),
  293. array('example.co.uk',
  294. '<a href="http://example.co.uk/" title="http://example.co.uk/" rel="nofollow external">example.co.uk</a>',
  295. 'bare_domains'),
  296. array('www.example.co.uk',
  297. '<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="nofollow external">www.example.co.uk</a>',
  298. 'bare_domains'),
  299. array('farm1.images.example.co.uk',
  300. '<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="nofollow external">farm1.images.example.co.uk</a>',
  301. 'bare_domains'),
  302. array('example.museum',
  303. '<a href="http://example.museum/" title="http://example.museum/" rel="nofollow external">example.museum</a>',
  304. 'bare_domains'),
  305. array('example.travel',
  306. '<a href="http://example.travel/" title="http://example.travel/" rel="nofollow external">example.travel</a>',
  307. 'bare_domains'),
  308. array('example.com.',
  309. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.',
  310. 'bare_domains'),
  311. array('example.com?',
  312. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>?',
  313. 'bare_domains'),
  314. array('example.com!',
  315. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>!',
  316. 'bare_domains'),
  317. array('example.com,',
  318. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>,',
  319. 'bare_domains'),
  320. array('example.com;',
  321. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>;',
  322. 'bare_domains'),
  323. array('example.com:',
  324. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>:',
  325. 'bare_domains'),
  326. array('\'example.com\'',
  327. '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>\'',
  328. 'bare_domains'),
  329. array('"example.com"',
  330. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&quot;',
  331. 'bare_domains'),
  332. array('example.com',
  333. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
  334. 'bare_domains'),
  335. array('(example.com)',
  336. '(<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>)',
  337. 'bare_domains'),
  338. array('[example.com]',
  339. '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>]',
  340. 'bare_domains'),
  341. array('<example.com>',
  342. '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&gt;',
  343. 'bare_domains'),
  344. array('Hey, check out my cool site example.com okay?',
  345. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a> okay?',
  346. 'bare_domains'),
  347. array('Hey, check out my cool site example.com.I made it.',
  348. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.I made it.',
  349. 'bare_domains'),
  350. array('Hey, check out my cool site example.com.Funny thing...',
  351. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.Funny thing...',
  352. 'bare_domains'),
  353. array('Hey, check out my cool site example.com.You will love it.',
  354. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.You will love it.',
  355. 'bare_domains'),
  356. array('example.com:8080/test.php',
  357. '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">example.com:8080/test.php</a>',
  358. 'bare_domains'),
  359. array('user_name+other@example.com',
  360. '<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="nofollow external">user_name+other@example.com</a>',
  361. 'bare_domains'),
  362. array('user@example.com',
  363. '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">user@example.com</a>',
  364. 'bare_domains'),
  365. );
  366. }
  367. }