URLDetectionTest.php 28 KB

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