URLDetectionTest.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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('PUBLICDIR')) {
  21. define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
  22. }
  23. if (!defined('GNUSOCIAL')) {
  24. define('GNUSOCIAL', true);
  25. }
  26. if (!defined('STATUSNET')) { // Compatibility
  27. define('STATUSNET', true);
  28. }
  29. use PHPUnit\Framework\TestCase;
  30. require_once INSTALLDIR . '/lib/util/common.php';
  31. final class URLDetectionTest extends TestCase
  32. {
  33. /**
  34. * @dataProvider provider
  35. * @param $content
  36. * @param $expected
  37. */
  38. public function testProduction($content, $expected)
  39. {
  40. $rendered = common_render_text($content);
  41. // hack!
  42. $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
  43. $this->assertEquals($expected, $rendered);
  44. }
  45. /**
  46. * @dataProvider linkifyProvider
  47. * @param $content
  48. * @param $expected
  49. * @param $config
  50. */
  51. public function testLinkifyProduction($content, $expected, $config)
  52. {
  53. $rendered = common_render_text($content);
  54. // hack!
  55. $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
  56. if (common_config('linkify', $config)) {
  57. $this->assertEquals($expected, $rendered);
  58. } else {
  59. $content = common_remove_unicode_formatting(nl2br(htmlspecialchars($content)));
  60. $this->assertEquals($content, $rendered);
  61. }
  62. }
  63. static public function provider()
  64. {
  65. return array(
  66. array('not a link :: no way',
  67. 'not a link :: no way'),
  68. array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
  69. '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'),
  70. array('http://127.0.0.1',
  71. '<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>'),
  72. array('http://[::1]:99/test.php',
  73. '<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="nofollow external">http://[::1]:99/test.php</a>'),
  74. array('http://::1/test.php',
  75. '<a href="http://::1/test.php" title="http://::1/test.php" rel="nofollow external">http://::1/test.php</a>'),
  76. array('http://::1',
  77. '<a href="http://::1/" title="http://::1/" rel="nofollow external">http://::1</a>'),
  78. array('http://127.0.0.1',
  79. '<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>'),
  80. array('http://example.com',
  81. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  82. array('http://example.com.',
  83. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  84. array('/var/lib/example.so',
  85. '/var/lib/example.so'),
  86. array('example',
  87. 'example'),
  88. array('mailto:user@example.com',
  89. '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">mailto:user@example.com</a>'),
  90. array('mailto:user@example.com?subject=test',
  91. '<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>'),
  92. array('xmpp:user@example.com',
  93. '<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="nofollow external">xmpp:user@example.com</a>'),
  94. array('#example',
  95. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
  96. array('#example.com',
  97. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example.com'))) . '" rel="tag">example.com</a></span>'),
  98. array('#.net',
  99. '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
  100. array('http://example',
  101. '<a href="http://example/" title="http://example/" rel="nofollow external">http://example</a>'),
  102. array('http://3xampl3',
  103. '<a href="http://3xampl3/" title="http://3xampl3/" rel="nofollow external">http://3xampl3</a>'),
  104. array('http://example/',
  105. '<a href="http://example/" title="http://example/" rel="nofollow external">http://example/</a>'),
  106. array('http://example/path',
  107. '<a href="http://example/path" title="http://example/path" rel="nofollow external">http://example/path</a>'),
  108. array('http://example.com',
  109. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  110. array('https://example.com',
  111. '<a href="https://example.com/" title="https://example.com/" rel="nofollow external">https://example.com</a>'),
  112. array('ftp://example.com',
  113. '<a href="ftp://example.com/" title="ftp://example.com/" rel="nofollow external">ftp://example.com</a>'),
  114. array('ftps://example.com',
  115. '<a href="ftps://example.com/" title="ftps://example.com/" rel="nofollow external">ftps://example.com</a>'),
  116. array('http://user@example.com',
  117. '<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user@example.com</a>'),
  118. array('http://user:pass@example.com',
  119. '<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user:pass@example.com</a>'),
  120. array('http://example.com:8080',
  121. '<a href="http://example.com:8080/" title="http://example.com:8080/" rel="nofollow external">http://example.com:8080</a>'),
  122. array('http://example.com:8080/test.php',
  123. '<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>'),
  124. array('http://www.example.com',
  125. '<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>'),
  126. array('http://example.com/',
  127. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>'),
  128. array('http://example.com/path',
  129. '<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>'),
  130. array('http://example.com/path.html',
  131. '<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>'),
  132. array('http://example.com/path.html#fragment',
  133. '<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>'),
  134. array('http://example.com/path.php?foo=bar&bar=foo',
  135. '<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>'),
  136. array('http://example.com.',
  137. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  138. array('http://müllärör.de',
  139. '<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>'),
  140. array('http://ﺱﺲﺷ.com',
  141. '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" title="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="nofollow external">http://ﺱﺲﺷ.com</a>'),
  142. array('http://сделаткартинки.com',
  143. '<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>'),
  144. array('http://tūdaliņ.lv',
  145. '<a href="http://t&#x16B;dali&#x146;.lv/" title="http://t&#x16B;dali&#x146;.lv/" rel="nofollow external">http://tūdaliņ.lv</a>'),
  146. array('http://brændendekærlighed.com',
  147. '<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>'),
  148. array('http://あーるいん.com',
  149. '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" title="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="nofollow external">http://あーるいん.com</a>'),
  150. array('http://예비교사.com',
  151. '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" title="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="nofollow external">http://예비교사.com</a>'),
  152. array('http://example.com.',
  153. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
  154. array('http://example.com?',
  155. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>?'),
  156. array('http://example.com!',
  157. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>!'),
  158. array('http://example.com,',
  159. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>,'),
  160. array('http://example.com;',
  161. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>;'),
  162. array('http://example.com:',
  163. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>:'),
  164. array('\'http://example.com\'',
  165. '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>\''),
  166. array('"http://example.com"',
  167. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>&quot;'),
  168. array('"http://example.com/"',
  169. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>&quot;'),
  170. array('http://example.com',
  171. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
  172. array('(http://example.com)',
  173. '(<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>)'),
  174. array('[http://example.com]',
  175. '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>]'),
  176. array('<http://example.com>',
  177. '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>&gt;'),
  178. array('http://example.com/path/(foo)/bar',
  179. '<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'),
  180. array('http://example.com/path/[foo]/bar',
  181. '<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'),
  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. //Not a valid url - urls cannot contain unencoded square brackets
  185. array('http://example.com/path/foo/[bar]',
  186. '<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]'),
  187. array('Hey, check out my cool site http://example.com okay?',
  188. '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?'),
  189. array('What about parens (e.g. http://example.com/path/foo/(bar))?',
  190. '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))?'),
  191. array('What about parens (e.g. http://example.com/path/foo/(bar)?',
  192. '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)?'),
  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/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar).)?'),
  195. //Not a valid url - urls cannot contain unencoded commas
  196. array('What about parens (e.g. http://example.com/path/(foo,bar)?',
  197. '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)?'),
  198. array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
  199. '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)?'),
  200. array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
  201. '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)?'),
  202. array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
  203. '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)?'),
  204. array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
  205. '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))))?'),
  206. array('file.ext',
  207. 'file.ext'),
  208. array('file.html',
  209. 'file.html'),
  210. array('file.php',
  211. 'file.php'),
  212. // scheme-less HTTP URLs with @ in the path: http://status.net/open-source/issues/2248
  213. array('http://flickr.com/photos/34807140@N05/3838905434',
  214. '<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>'),
  215. );
  216. }
  217. static public function linkifyProvider()
  218. {
  219. return array(
  220. //bare ip addresses are no longer supported
  221. array('127.0.0.1',
  222. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1</a>',
  223. 'bare_ipv4'),
  224. array('127.0.0.1:99',
  225. '<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="nofollow external">127.0.0.1:99</a>',
  226. 'bare_ipv4'),
  227. array('127.0.0.1/Name:test.php',
  228. '<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>',
  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/\'test" title="http://127.0.0.1/\'test" rel="nofollow external">127.0.0.1/\'test</a>',
  241. 'bare_ipv4'),
  242. array('127.0.0.1/"test',
  243. '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1/</a>&quot;test',
  244. 'bare_ipv4'),
  245. array('127.0.0.1/test"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>&quot;test',
  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',
  258. '<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="nofollow external">127.0.0.1/*test</a>',
  259. 'bare_ipv4'),
  260. array('127.0.0.1/test%20stuff',
  261. '<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>',
  262. 'bare_ipv4'),
  263. array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
  264. '<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>',
  265. 'bare_ipv6'),
  266. array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
  267. '<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>',
  268. 'bare_ipv6'),
  269. array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
  270. '<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>',
  271. 'bare_ipv6'),
  272. array('example.com',
  273. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
  274. 'bare_domains'),
  275. array('flickr.com/photos/34807140@N05/3838905434',
  276. '<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>',
  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('What about parens (e.g. example.com/path/(foo,bar)?',
  288. '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>?',
  289. 'bare_domains'),
  290. array('example.com',
  291. '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
  292. 'bare_domains'),
  293. array('example.org',
  294. '<a href="http://example.org/" title="http://example.org/" rel="nofollow external">example.org</a>',
  295. 'bare_domains'),
  296. array('example.co.uk',
  297. '<a href="http://example.co.uk/" title="http://example.co.uk/" rel="nofollow external">example.co.uk</a>',
  298. 'bare_domains'),
  299. array('www.example.co.uk',
  300. '<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="nofollow external">www.example.co.uk</a>',
  301. 'bare_domains'),
  302. array('farm1.images.example.co.uk',
  303. '<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="nofollow external">farm1.images.example.co.uk</a>',
  304. 'bare_domains'),
  305. array('example.museum',
  306. '<a href="http://example.museum/" title="http://example.museum/" rel="nofollow external">example.museum</a>',
  307. 'bare_domains'),
  308. array('example.travel',
  309. '<a href="http://example.travel/" title="http://example.travel/" rel="nofollow external">example.travel</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. '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>\'',
  331. 'bare_domains'),
  332. array('"example.com"',
  333. '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&quot;',
  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. '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>]',
  343. 'bare_domains'),
  344. array('<example.com>',
  345. '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&gt;',
  346. 'bare_domains'),
  347. array('Hey, check out my cool site example.com okay?',
  348. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a> okay?',
  349. 'bare_domains'),
  350. array('Hey, check out my cool site example.com.I made it.',
  351. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.I made it.',
  352. 'bare_domains'),
  353. array('Hey, check out my cool site example.com.Funny thing...',
  354. 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.Funny thing...',
  355. 'bare_domains'),
  356. array('Hey, check out my cool site example.com.You will love it.',
  357. '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.',
  358. 'bare_domains'),
  359. array('example.com:8080/test.php',
  360. '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">example.com:8080/test.php</a>',
  361. 'bare_domains'),
  362. array('user_name+other@example.com',
  363. '<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="nofollow external">user_name+other@example.com</a>',
  364. 'bare_domains'),
  365. array('user@example.com',
  366. '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">user@example.com</a>',
  367. 'bare_domains'),
  368. );
  369. }
  370. }