Debian Codegraph @

tests/parser/extLinks.txt

raw
1 ### This file has tests for external and url links
2
3 # The parsoid-compatible option below is only relevant when we are running
4 # parser tests in integrated mode with Parsoid. This option is ignored
5 # when this test file is run with Parsoid in standalone mode.
6 !! options
7 parsoid-compatible=wt2html,wt2wt
8 version=2
9 !! end
10
11 !! article
12 Template:1x
13 !! text
14 {{{1}}}
15 !! endarticle
16
17 !! article
18 Wikilink
19 !! text
20 Dummy article to suppress redlinks in tests
21 !! end
22
23 !! article
24 Museo Picasso (París)
25 !! text
26 Dummy article to suppress redlinks in tests
27 !! end
28
29 !! test
30 External links: non-bracketed
31 !! options
32 extlinks
33 !! wikitext
34 Non-bracketed: http://example.com
35 !! metadata
36 extlink=http://example.com
37 !! html
38 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
39 </p>
40 !! end
41
42 # parsoid doesn't explicitly mark autonumbered links, see T55505
43 !! test
44 External links: numbered
45 !! wikitext
46 Numbered: [http://example.com]
47 Numbered: [http://example.net]
48 Numbered: [http://example.com]
49 !! html/php
50 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
51 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
52 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
53 </p>
54 !! html/parsoid
55 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com" class="external autonumber"></a>
56 Numbered: <a rel="mw:ExtLink" href="http://example.net" class="external autonumber"></a>
57 Numbered: <a rel="mw:ExtLink" href="http://example.com" class="external autonumber"></a></p>
58 !!end
59
60 !! test
61 External links: specified text
62 !! wikitext
63 Specified text: [http://example.com link]
64 !! html
65 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
66 </p>
67 !!end
68
69 !! test
70 External links: trail
71 !! wikitext
72 Linktrails should not work for external links: [http://example.com link]s
73 !! html
74 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
75 </p>
76 !! end
77
78 !! test
79 External links: dollar sign in URL
80 !! wikitext
81 http://example.com/1$2345
82 !! html
83 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
84 </p>
85 !! end
86
87 # parsoid doesn't explicitly mark autonumbered links, see T55505
88 !! test
89 External links: dollar sign in URL (autonumber)
90 !! wikitext
91 [http://example.com/1$2345]
92 !! html/php
93 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
94 </p>
95 !! html/parsoid
96 <p><a rel="mw:ExtLink" href="http://example.com/1$2345" class="external autonumber"></a></p>
97 !!end
98
99 !! test
100 External links: open square bracket forbidden in URL (T6377)
101 !! options
102 parsoid=wt2html,wt2wt,html2html
103 !! wikitext
104 http://example.com/1[2345
105 !! html/php
106 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
107 </p>
108 !! html/parsoid
109 <p><a rel="mw:ExtLink" href="http://example.com/1" class="external free">http://example.com/1</a>[2345</p>
110 !! end
111
112 !! test
113 External links: open square bracket forbidden in URL (named) (T6377)
114 !! options
115 parsoid=wt2html,html2html
116 !! wikitext
117 [http://example.com/1[2345]
118 !! html/php
119 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
120 </p>
121 !! html/parsoid
122 <p><a rel="mw:ExtLink" href="http://example.com/1" class="external text">[2345</a></p>
123 !!end
124
125 # parsoid adds a space before the link name
126 !! test
127 External links: open square bracket forbidden in URL (named) (T6377)
128 Parsoid variant.
129 !! wikitext
130 [http://example.com/1 [2345]
131 !! html
132 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
133 </p>
134 !!end
135
136 !! test
137 External links: nowiki in URL link text (T8230)
138 !! wikitext
139 [http://example.com/ <nowiki>''example site''</nowiki>]
140 !! html
141 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
142 </p>
143 !! end
144
145 !! test
146 External links: newline forbidden in text (T8230 regression check)
147 !! wikitext
148 [http://example.com/ first
149 second]
150 !! html
151 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
152 second]
153 </p>
154 !!end
155
156 !! test
157 External links: Pipe char between url and text
158 !! wikitext
159 [http://example.com | link]
160 !! html
161 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
162 </p>
163 !!end
164
165 !! test
166 External links: protocol-relative URL in brackets
167 !! wikitext
168 [//example.com/ Test]
169 !! html
170 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
171 </p>
172 !! end
173
174 # parsoid doesn't explicitly mark autonumbered links, see T55505
175 !! test
176 External links: protocol-relative URL in brackets without text
177 !! wikitext
178 [//example.com]
179 !! html/php
180 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
181 </p>
182 !! html/parsoid
183 <p><a rel="mw:ExtLink" href="//example.com" class="external autonumber"></a></p>
184 !! end
185
186 !! test
187 External links: protocol-relative URL in free text is left alone
188 !! wikitext
189 //example.com/Foo
190 !! html
191 <p>//example.com/Foo
192 </p>
193 !!end
194
195 !! test
196 External links: protocol-relative URL in the middle of a word is left alone (T32269)
197 !! wikitext
198 foo//example.com/Foo
199 !! html
200 <p>foo//example.com/Foo
201 </p>
202 !! end
203
204 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
205 !! test
206 External links: with no contents
207 !! options
208 parsoid=wt2html,wt2wt
209 !! wikitext
210 [http://en.wikipedia.org/wiki/Foo]
211
212 [[wikipedia:Foo|Bar]]
213
214 [[wikipedia:Foo|<span>Bar</span>]]
215 !! html/php
216 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
217 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
218 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
219 </p>
220 !! html/parsoid
221 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" class="external autonumber"></a></p>
222 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo" class="extiw">Bar</a></p>
223 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo" class="extiw"><span>Bar</span></a></p>
224 !! end
225
226 !! test
227 External links: Free with trailing punctuation
228 !! wikitext
229 http://example.com,
230 http://example.com;
231 http://example.com\
232 http://example.com.
233 http://example.com:
234 http://example.com!
235 http://example.com?
236 http://example.com)
237 http://example.com/url_with_(brackets)
238 (http://example.com/url_without_brackets)
239 http://example.com/url_with_entity&amp;
240 http://example.com/url_with_entity&#x26;
241 http://example.com/url_with_entity&#038;
242 http://example.com/url_with_entity&nbsp;
243 http://example.com/url_with_entity&#xA0;
244 http://example.com/url_with_entity&#160;
245 http://example.com/url_with_entity&lt;
246 http://example.com/url_with_entity&#x3C;
247 http://example.com/url_with_entity&#60;
248 !! html/php
249 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
250 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
251 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
252 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
253 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
254 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
255 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
256 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
257 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
258 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
259 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
260 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
261 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
262 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
263 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
264 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
265 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
266 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
267 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
268 </p>
269 !! html/parsoid
270 <p><a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>,
271 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>;
272 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>\
273 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>.
274 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>:
275 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>!
276 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>?
277 <a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url"}'>http://example.com</a>)
278 <a rel="mw:ExtLink" href="http://example.com/url_with_(brackets)" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_(brackets)</a>
279 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_without_brackets</a>)
280 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/url_with_entity&amp;"},"sa":{"href":"http://example.com/url_with_entity&amp;amp;"}}'>http://example.com/url_with_entity&amp;</a>
281 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/url_with_entity&amp;"},"sa":{"href":"http://example.com/url_with_entity&amp;#x26;"}}'>http://example.com/url_with_entity&amp;</a>
282 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/url_with_entity&amp;"},"sa":{"href":"http://example.com/url_with_entity&amp;#038;"}}'>http://example.com/url_with_entity&amp;</a>
283 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>
284 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span>
285 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span>
286 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>
287 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x3C;","srcContent":"&lt;"}'>&lt;</span>
288 <a rel="mw:ExtLink" href="http://example.com/url_with_entity" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#60;","srcContent":"&lt;"}'>&lt;</span></p>
289 !! end
290
291 !! test
292 External links: tricky Parsoid html2html case
293 !! options
294 parsoid=wt2html,wt2wt,html2html
295 !! wikitext
296 http://example.com/url_with_entity&amp;amp;
297 !! html/php
298 <p><a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;
299 </p>
300 !! html/parsoid
301 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp" class="external free">http://example.com/url_with_entity&amp;amp</a>;</p>
302 !! end
303
304 !! test
305 External links: html2html with trailing dot (T263203)
306 !! wikitext
307 test [http://example.com/test. http://example.com/test.] test
308
309 test http://example.com/test. test
310 !! html/parsoid
311 <p>test <a rel="mw:ExtLink" href="http://example.com/test." class="external text">http://example.com/test.</a> test</p>
312
313 <p>test <a rel="mw:ExtLink" href="http://example.com/test" class="external free" data-parsoid='{"stx":"url"}'>http://example.com/test</a>. test</p>
314 !! html/php
315 <p>test <a rel="nofollow" class="external text" href="http://example.com/test.">http://example.com/test.</a> test
316 </p><p>test <a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>. test
317 </p>
318 !! end
319
320 !! test
321 External links: Free with trailing quotes (T113666)
322 !! wikitext
323 '''News:''' Stuff here
324
325 news:'a'b''c''d e
326 !! html/php
327 <p><b>News:</b> Stuff here
328 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:&#39;a&#39;b</a><i>c</i>d e
329 </p>
330 !! html/parsoid
331 <p><b>News:</b> Stuff here</p>
332 <p><a rel="mw:ExtLink" href="news:'a'b" class="external free">news:'a'b</a><i>c</i>d e</p>
333 !! end
334
335 !! test
336 External links: with entity
337 !! wikitext
338 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
339 !! html/php
340 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
341 </p>
342 !! html/parsoid
343 <p><a rel="mw:ExtLink" href="http://+www.librarieswithoutborders.org" class="external text" data-parsoid='{"a":{"href":"http://+www.librarieswithoutborders.org"},"sa":{"href":"http://&amp;#x20;www.librarieswithoutborders.org"}}'>Libraries without borders</a></p>
344 !! end
345
346 !! test
347 External links: Lone protocols are never linked (T105697)
348 !! wikitext
349 http://
350 http://;
351 (http://)
352 bitcoin:
353 bitcoin:;
354 (bitcoin:)
355 !! html
356 <p>http://
357 http://;
358 (http://)
359 bitcoin:
360 bitcoin:;
361 (bitcoin:)
362 </p>
363 !! end
364
365 !! test
366 External links: No preceding word characters allowed (T67278)
367 !! wikitext
368 NOPEhttp://example.com
369 N0http://example.com
370 ok:http://example.com
371 ok-http://example.com
372 !! html
373 <p>NOPEhttp://example.com
374 N0http://example.com
375 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
376 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
377 </p>
378 !! end
379
380 !! test
381 External links: nofollow domain exception
382 !! wikitext
383 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
384 !! html
385 <p>A <a class="external text" href="https://no-nofollow.org/foobar">link</a>, and another <a rel="nofollow" class="external text" href="https://example.org">link</a>.
386 </p>
387 !!end
388
389 !! test
390 External image
391 !! wikitext
392 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
393 !! html
394 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
395 </p>
396 !! end
397
398 !! test
399 External image from https
400 !! wikitext
401 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
402 !! html
403 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
404 </p>
405 !! end
406
407 !! test
408 External image (when not allowed)
409 !! options
410 wgAllowExternalImages=0
411 !! wikitext
412 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
413 !! html/php
414 <p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a>
415 </p>
416 !! html/parsoid
417 <p>External image: <a rel="mw:ExtLink" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" class="external free" data-parsoid='{"stx":"url"}'>http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a></p>
418 !! html/parsoid+integrated
419 <p>External image: <a rel="mw:ExtLink nofollow" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" class="external free" data-parsoid='{"stx":"url"}'>http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a></p>
420 !! end
421
422 !! test
423 Link to non-http image, no img tag
424 !! wikitext
425 Link to non-http image, no img tag: ftp://example.com/test.jpg
426 !! html
427 <p>Link to non-http image, no img tag: <a rel="nofollow" class="external free" href="ftp://example.com/test.jpg">ftp://example.com/test.jpg</a>
428 </p>
429 !! end
430
431 !! test
432 External links: terminating separator
433 !! wikitext
434 Terminating separator: http://example.com/thing,
435 !! html
436 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
437 </p>
438 !! end
439
440 !! test
441 External links: intervening separator
442 !! wikitext
443 Intervening separator: http://example.com/1,2,3
444 !! html
445 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
446 </p>
447 !! end
448
449 !! test
450 External links: old bug with URL in query
451 !! wikitext
452 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
453 !! html
454 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
455 </p>
456 !! end
457
458 !! test
459 External links: old URL-in-URL bug, mixed protocols
460 !! wikitext
461 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
462 !! html
463 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
464 </p>
465 !!end
466
467 # Since Parsoid is starting to emit canonical wikitext for links,
468 # [http://example.com http://example.com] will not RT back to that
469 # form anymore.
470 !! test
471 External links: URL in text
472 !! options
473 parsoid=wt2html
474 !! wikitext
475 URL in text: [http://example.com http://example.com]
476 !! html/php
477 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
478 </p>
479 !! html/parsoid
480 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com" class="external text">http://example.com</a></p>
481 !! end
482
483 !! test
484 External links: Clickable images
485 !! wikitext
486 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
487 !! html/php
488 <p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
489 </p>
490 !! html/parsoid
491 <p>ja-style clickable images: <a rel="mw:ExtLink" href="http://example.com" class="external text"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
492 !! end
493
494 !! test
495 External links: raw ampersand
496 !! options
497 extlinks
498 !! wikitext
499 Old &amp; use: http://x&y
500 !! metadata
501 extlink=http://x&y
502 !! html
503 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
504 </p>
505 !! end
506
507 !! test
508 External links: encoded ampersand
509 !! options
510 extlinks
511 !! wikitext
512 Old &amp; use: http://x&amp;y
513 !! metadata
514 extlink=http://x&y
515 !! html/php
516 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
517 </p>
518 !! html/parsoid
519 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y" class="external free">http://x&amp;y</a></p>
520 !! end
521
522 !! test
523 External links: encoded equals (T8102)
524 !! options
525 extlinks
526 !! wikitext
527 http://example.com/?foo&#61;bar
528 !! metadata
529 extlink=http://example.com/?foo=bar
530 !! html/php
531 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
532 </p>
533 !! html/parsoid
534 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar" class="external free">http://example.com/?foo=bar</a></p>
535 !! end
536
537 ##
538 ## Note that parsoid doesn't explicit mark autonumbered links, nor
539 ## does it number them. As discussed in T55505, we can identify
540 ## autonumbered links via CSS.
541 ##
542
543 !! test
544 External links: [raw ampersand]
545 !! options
546 extlinks
547 !! wikitext
548 Old &amp; use: [http://x&y]
549 !! metadata
550 extlink=http://x&y
551 !! html/php
552 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
553 </p>
554 !! html/parsoid
555 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y" class="external autonumber"></a></p>
556 !! end
557
558 # note that parsoid html is identical to [raw ampersand] case; so html2wt
559 # mode will return the [raw ampersand] wikitext
560 !! test
561 External links: [encoded ampersand]
562 !! options
563 parsoid=wt2html,wt2wt,html2html
564 extlinks
565 !! wikitext
566 Old &amp; use: [http://x&amp;y]
567 !! metadata
568 extlink=http://x&y
569 !! html/php
570 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
571 </p>
572 !! html/parsoid
573 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y" class="external autonumber"></a></p>
574 !! end
575
576 !! test
577 External links: [raw equals]
578 !! options
579 extlinks
580 !! wikitext
581 [http://example.com/?foo=bar]
582 !! metadata
583 extlink=http://example.com/?foo=bar
584 !! html/php
585 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
586 </p>
587 !! html/parsoid
588 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar" class="external autonumber"></a></p>
589 !! end
590
591 # note that parsoid html is identical to [raw equals] case; so html2wt
592 # mode will return the [raw equals] wikitext
593 !! test
594 External links: [encoded equals] (T8102)
595 !! options
596 parsoid=wt2html,wt2wt,html2html
597 extlinks
598 !! wikitext
599 [http://example.com/?foo&#61;bar]
600 !! metadata
601 extlink=http://example.com/?foo=bar
602 !! html/php
603 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
604 </p>
605 !! html/parsoid
606 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar" class="external autonumber"></a></p>
607 !! end
608
609 # xxx parsoid strips the IDN character, so the round-trip tests will
610 # obviously fail and are disabled. --cscott
611 !! test
612 External links: [IDN ignored character reference in hostname; strip it right off]
613 !! options
614 parsoid=wt2html,wt2wt,html2html
615 !! wikitext
616 [http://e&zwnj;xample.com/]
617 !! html/php
618 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
619 </p>
620 !! html/parsoid
621 <p><a rel="mw:ExtLink" href="http://example.com/" class="external autonumber"></a></p>
622 !! end
623
624 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
625 # Where an external link could easily circumvent the sanitization of the text of
626 # a link like this (where an IDN-ignore character is in the URL somewhere), this
627 # test demands a higher standard. That's a bit strange.
628 #
629 # Example:
630 #
631 # http://e‌xample.com -> [http://example.com|http://example.com]
632 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
633 #
634 # The first example is sanitized, but the second is not. Any security benefits
635 # from this production are trivial to circumvent. Either remove this test and
636 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
637 # the test accordingly.
638 #
639 # All our love,
640 # The Parsoid team.
641 # xxx parsoid strips the IDN character, so the round-trip tests will
642 # obviously fail and are disabled. --cscott
643 !! test
644 External links: IDN ignored character reference in hostname; strip it right off
645 !! options
646 parsoid=wt2html,html2html
647 !! wikitext
648 http://e&zwnj;xample.com/
649 !! html/php
650 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
651 </p>
652 !! html/parsoid
653 <p><a rel="mw:ExtLink" href="http://example.com/" class="external free">http://example.com/</a></p>
654 !! end
655
656 !! test
657 External links: www.jpeg.org (T2554)
658 !! wikitext
659 http://www.jpeg.org
660 !! html
661 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
662 </p>
663 !! end
664
665 # parsoid doesn't explicitly mark autonumbered links, see T55505
666 !! test
667 External links: URL within URL (T2002)
668 !! wikitext
669 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
670 !! html/php
671 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
672 </p>
673 !! html/parsoid
674 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class="external autonumber"></a></p>
675 !! end
676
677 !! test
678 T2361: URL inside bracketed URL
679 !! wikitext
680 [http://www.example.com/foo http://www.example.com/bar]
681 !! html
682 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
683 </p>
684 !! end
685
686 !! test
687 T2361: URL within URL, not bracketed
688 !! wikitext
689 http://www.example.com/foo?=http://www.example.com/bar
690 !! html
691 <p><a rel="nofollow" class="external free" href="http://www.example.com/foo?=http://www.example.com/bar">http://www.example.com/foo?=http://www.example.com/bar</a>
692 </p>
693 !! end
694
695 !! test
696 T2289: ">"-token in URL-tail
697 !! wikitext
698 http://www.example.com/<hello>
699 !! html
700 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
701 </p>
702 !!end
703
704 !! test
705 T2289: literal ">"-token in URL-tail
706 !! wikitext
707 http://www.example.com/<b>html</b>
708 !! html/php
709 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
710 </p>
711 !! html/parsoid
712 <p><a rel="mw:ExtLink" href="http://www.example.com/" class="external free" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p>
713 !! end
714
715 !! test
716 T2289: ">"-token in bracketed URL
717 !! wikitext
718 [http://www.example.com/<hello> stuff]
719 !! html
720 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
721 </p>
722 !!end
723
724 !! test
725 T2289: literal ">"-token in bracketed URL
726 !! wikitext
727 [http://www.example.com/<b>html</b> stuff]
728 !! html
729 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
730 </p>
731 !!end
732
733 !! test
734 T2289: literal double quote at end of URL
735 !! wikitext
736 http://www.example.com/"hello"
737 !! html
738 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
739 </p>
740 !!end
741
742 !! test
743 T2289: literal double quote in bracketed URL
744 !! wikitext
745 [http://www.example.com/"hello" stuff]
746 !! html
747 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
748 </p>
749 !!end
750
751 !! test
752 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
753 !! wikitext
754 [http://www.example.com test]
755 !! html
756 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
757 </p>
758 !! end
759
760 !! test
761 External links: link text with spaces
762 !! wikitext
763 [http://www.example.com a b c]
764 [http://www.example.com ''a'' ''b'']
765 !! html
766 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
767 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
768 </p>
769 !! end
770
771 # Note edge case difference between PHP and Parsoid here.
772 !! test
773 External links: wiki links within external link (T5695)
774 !! options
775 parsoid=wt2html
776 !! wikitext
777 [http://example.com [[wikilink]] embedded in ext link]
778
779 [http://example.com test [[wikilink]] embedded in ext link]
780 !! html/php
781 <p><a rel="nofollow" class="external text" href="http://example.com"></a><a href="/wiki/Wikilink" title="Wikilink">wikilink</a> embedded in ext link
782 </p><p><a rel="nofollow" class="external text" href="http://example.com">test </a><a href="/wiki/Wikilink" title="Wikilink">wikilink</a> embedded in ext link
783 </p>
784 !! html/parsoid
785 <p><a rel="mw:ExtLink nofollow" href="http://example.com" class="external autonumber"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink" data-parsoid='{"stx":"simple","a":{"href":"./Wikilink"},"sa":{"href":"wikilink"},"misnested":true}'>wikilink</a><span data-parsoid='{"misnested":true}'> embedded in ext link</span></p>
786
787 <p><a rel="mw:ExtLink nofollow" href="http://example.com" class="external text">test </a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink" data-parsoid='{"stx":"simple","a":{"href":"./Wikilink"},"sa":{"href":"wikilink"},"misnested":true}'>wikilink</a><span data-parsoid='{"misnested":true}'> embedded in ext link</span></p>
788 !! end
789
790 !! test
791 T2787: Links with one slash after the url protocol are invalid
792 !! wikitext
793 http:/example.com
794
795 [http:/example.com title]
796 !! html
797 <p>http:/example.com
798 </p><p>[http:/example.com title]
799 </p>
800 !! end
801
802 !! test
803 Bracketed external links with template-generated invalid target
804 !! wikitext
805 [{{1x|http:/example.com}} title]
806 !! html
807 <p>[http:/example.com title]
808 </p>
809 !! end
810
811 !! test
812 T6781: %26 in URL
813 !! wikitext
814 http://www.example.com/?title=AT%26T
815 !! html/php
816 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
817 </p>
818 !! html/parsoid
819 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T" class="external free">http://www.example.com/?title=AT%26T</a></p>
820 !! end
821
822 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
823 # % is actually legal in HTML5. Any change in output would need testing though.
824 !! test
825 T6781, T7267: %25 in URL
826 !! wikitext
827 http://www.example.com/?title=100%25_Bran
828 !! html/php
829 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a>
830 </p>
831 !! html/parsoid
832 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran" class="external free">http://www.example.com/?title=100%25_Bran</a></p>
833 !! end
834
835 !! test
836 T6781, T7267: %28, %29 in URL
837 !! wikitext
838 http://www.example.com/?title=Ben-Hur_%281959_film%29
839 !! html/php
840 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
841 </p>
842 !! html/parsoid
843 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class="external free">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p>
844 !! end
845
846
847 !! test
848 T6781: %26 in autonumber URL
849 !! wikitext
850 [http://www.example.com/?title=AT%26T]
851 !! html/php
852 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
853 </p>
854 !! html/parsoid
855 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T" class="external autonumber"></a></p>
856 !! end
857
858 !! test
859 T6781, T7267: %26 in autonumber URL
860 !! wikitext
861 [http://www.example.com/?title=100%25_Bran]
862 !! html/php
863 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
864 </p>
865 !! html/parsoid
866 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran" class="external autonumber"></a></p>
867 !! end
868
869 !! test
870 T6781, T7267: %28, %29 in autonumber URL
871 !! wikitext
872 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
873 !! html/php
874 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
875 </p>
876 !! html/parsoid
877 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class="external autonumber"></a></p>
878 !! end
879
880
881 !! test
882 T6781: %26 in bracketed URL
883 !! wikitext
884 [http://www.example.com/?title=AT%26T link]
885 !! html/php
886 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
887 </p>
888 !! html/parsoid
889 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T" class="external text">link</a></p>
890 !! end
891
892 !! test
893 T6781, T7267: %25 in bracketed URL
894 !! wikitext
895 [http://www.example.com/?title=100%25_Bran link]
896 !! html
897 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
898 </p>
899 !! end
900
901 !! test
902 T6781, T7267: %28, %29 in bracketed URL
903 !! wikitext
904 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
905 !! html/php
906 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
907 </p>
908 !! html/parsoid
909 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class="external text">link</a></p>
910 !! end
911
912 !! test
913 External link containing a period in the anchor. (T65947)
914 !! wikitext
915 [//foo.org/bar#baz. bang]
916
917 [//foo.org/bar. bang]
918 !! html/php
919 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
920 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
921 </p>
922 !! html/parsoid
923 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz." class="external text">bang</a></p>
924 <p><a rel="mw:ExtLink" href="//foo.org/bar." class="external text">bang</a></p>
925 !! end
926
927 !! test
928 External link containing a single quote. (T65947)
929 !! wikitext
930 [//foo.org/bar'baz]
931
932 [//foo.org/bar'baz bang]
933 !! html/php
934 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
935 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
936 </p>
937 !! html/parsoid
938 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz" class="external autonumber"></a></p>
939 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz" class="external text">bang</a></p>
940 !! end
941
942 !! test
943 External link containing double-single-quotes in text '' (T6598 check)
944 !! wikitext
945 Some [http://example.com/ pretty ''italics'' and stuff]!
946 !! html
947 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
948 </p>
949 !! end
950
951 # Note different rendering by Parsoid here compared to the legacy parser.
952 !! test
953 External link containing double-single-quotes in text embedded in italics (T6598 check)
954 !! wikitext
955 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
956 !! html/php
957 <p><i>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty </a></i><a rel="nofollow" class="external text" href="http://example.com/">italics<i> and stuff</i></a><i>!</i>
958 </p>
959 !! html/parsoid
960 <p><i>Some <a rel="mw:ExtLink" href="http://example.com/" class="external text">pretty <i>italics</i> and stuff</a>!</i></p>
961 !! end
962
963 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
964 !! test
965 External link containing double-single-quotes with no space separating the url from text in italics
966 !! wikitext
967 [http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].]
968 !! html/php
969 <p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a href="/wiki/Museo_Picasso_(Par%C3%ADs)" title="Museo Picasso (París)">Museo Picasso</a>.
970 </p>
971 !! html/parsoid
972 <p><a rel="mw:ExtLink nofollow" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm" class="external text"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)" data-parsoid='{"stx":"piped","a":{"href":"./Museo_Picasso_(París)"},"sa":{"href":"Museo Picasso (París)"},"misnested":true}' >Museo Picasso</a><span data-parsoid='{"misnested":true}'>.</span></p>
973 !! end
974
975 !! test
976 External link with comments in link text
977 !! wikitext
978 [http://www.google.com Google <!-- comment -->]
979 !! html/php
980 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
981 </p>
982 !! html/parsoid
983 <p><a rel="mw:ExtLink" href="http://www.google.com" class="external text">Google <!-- comment --></a></p>
984 !! end
985
986 !! test
987 External link to bare IPv4 address
988 !! wikitext
989 [http://192.168.0.1 Link]
990 !! html/php
991 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
992 </p>
993 !! html/parsoid
994 <p><a rel="mw:ExtLink" href="http://192.168.0.1" class="external text">Link</a></p>
995 !! end
996
997 !! test
998 URL-encoding in URL functions (single parameter)
999 !! wikitext
1000 {{localurl:Some page|amp=&}}
1001 !! html
1002 <p>/index.php?title=Some_page&amp;amp=&amp;
1003 </p>
1004 !! end
1005
1006 !! test
1007 URL-encoding in URL functions (multiple parameters)
1008 !! wikitext
1009 {{localurl:Some page|q=?&amp=&}}
1010 !! html
1011 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
1012 </p>
1013 !! end
1014
1015 !! test
1016 Brackets in urls
1017 !! wikitext
1018 http://example.com/index.php?foozoid%5B%5D=bar
1019
1020 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
1021 !! html/php
1022 <p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
1023 </p><p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
1024 </p>
1025 !! html/parsoid
1026 <p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar" class="external free">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
1027
1028 <p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/index.php?foozoid%5B%5D=bar"},"sa":{"href":"http://example.com/index.php?foozoid&amp;#x5B;&amp;#x5D;=bar"}}'>http://example.com/index.php?foozoid%5B%5D=bar</a></p>
1029 !! end
1030
1031 !! test
1032 IPv6 urls, autolink format (T23261)
1033 !! wikitext
1034 http://[2404:130:0:1000::187:2]/index.php
1035
1036 Examples from RFC 2373, section 2.2:
1037
1038 *http://[1080::8:800:200C:417A]/unicast
1039 *http://[FF01::101]/multicast
1040 *http://[::1]/loopback
1041 *http://[::]/unspecified
1042 *http://[::13.1.68.3]/ipv4compat
1043 *http://[::FFFF:129.144.52.38]/ipv4compat
1044
1045 Examples from RFC 2732, section 2:
1046
1047 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
1048 *http://[1080:0:0:0:8:800:200C:417A]/index.html
1049 *http://[3ffe:2a00:100:7031::1]
1050 *http://[1080::8:800:200C:417A]/foo
1051 *http://[::192.9.5.5]/ipng
1052 *http://[::FFFF:129.144.52.38]:80/index.html
1053 *http://[2010:836B:4179::836B:4179]
1054 !! html/php
1055 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
1056 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://datatracker.ietf.org/doc/html/rfc2373">RFC 2373</a>, section 2.2:
1057 </p>
1058 <ul><li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
1059 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
1060 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
1061 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
1062 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
1063 <li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
1064 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://datatracker.ietf.org/doc/html/rfc2732">RFC 2732</a>, section 2:
1065 </p>
1066 <ul><li><a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
1067 <li><a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
1068 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
1069 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
1070 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
1071 <li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
1072 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
1073 !! html/parsoid
1074 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php" class="external free">http://[2404:130:0:1000::187:2]/index.php</a></p>
1075
1076 <p>Examples from <a href="https://datatracker.ietf.org/doc/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
1077 <ul><li><a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast" class="external free">http://[1080::8:800:200C:417A]/unicast</a></li>
1078 <li><a rel="mw:ExtLink" href="http://[FF01::101]/multicast" class="external free">http://[FF01::101]/multicast</a></li>
1079 <li><a rel="mw:ExtLink" href="http://[::1]/loopback" class="external free">http://[::1]/loopback</a></li>
1080 <li><a rel="mw:ExtLink" href="http://[::]/unspecified" class="external free">http://[::]/unspecified</a></li>
1081 <li><a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat" class="external free">http://[::13.1.68.3]/ipv4compat</a></li>
1082 <li><a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat" class="external free">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
1083
1084 <p>Examples from <a href="https://datatracker.ietf.org/doc/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
1085 <ul><li><a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html" class="external free">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
1086 <li><a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html" class="external free">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
1087 <li><a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]" class="external free">http://[3ffe:2a00:100:7031::1]</a></li>
1088 <li><a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo" class="external free">http://[1080::8:800:200C:417A]/foo</a></li>
1089 <li><a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng" class="external free">http://[::192.9.5.5]/ipng</a></li>
1090 <li><a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html" class="external free">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
1091 <li><a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]" class="external free">http://[2010:836B:4179::836B:4179]</a></li></ul>
1092 !! end
1093
1094 # It might make sense to change this behavior; see
1095 # See https://phabricator.wikimedia.org/T238022#5665580
1096 !! test
1097 Unicode text around autolinks
1098 !! wikitext
1099 größhttps://foo.org
1100
1101 größ https://foo.org
1102
1103 아들 고건 사진https://foo.org
1104
1105 💩https://foo.org
1106 !! html/php
1107 <p>größhttps://foo.org
1108 </p><p>größ <a rel="nofollow" class="external free" href="https://foo.org">https://foo.org</a>
1109 </p><p>아들 고건 사진https://foo.org
1110 </p><p>💩<a rel="nofollow" class="external free" href="https://foo.org">https://foo.org</a>
1111 </p>
1112 !! html/parsoid
1113 <p>größhttps://foo.org</p>
1114
1115 <p>größ <a rel="mw:ExtLink" href="https://foo.org" class="external free" data-parsoid='{"stx":"url"}'>https://foo.org</a></p>
1116
1117 <p>아들 고건 사진https://foo.org</p>
1118
1119 <p>💩<a rel="mw:ExtLink" href="https://foo.org" class="external free" data-parsoid='{"stx":"url"}'>https://foo.org</a></p>
1120 !! end
1121
1122 !! test
1123 IPv6 urls, bracketed format (T23261)
1124 !! wikitext
1125 [http://[2404:130:0:1000::187:2]/index.php test]
1126
1127 Examples from RFC 2373, section 2.2:
1128
1129 *[http://[1080::8:800:200C:417A] unicast]
1130 *[http://[FF01::101] multicast]
1131 *[http://[::1]/ loopback]
1132 *[http://[::] unspecified]
1133 *[http://[::13.1.68.3] ipv4compat]
1134 *[http://[::FFFF:129.144.52.38] ipv4compat]
1135
1136 Examples from RFC 2732, section 2:
1137
1138 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
1139 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
1140 *[http://[3ffe:2a00:100:7031::1] 3]
1141 *[http://[1080::8:800:200C:417A]/foo 4]
1142 *[http://[::192.9.5.5]/ipng 5]
1143 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
1144 *[http://[2010:836B:4179::836B:4179] 7]
1145 !! html/php
1146 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
1147 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://datatracker.ietf.org/doc/html/rfc2373">RFC 2373</a>, section 2.2:
1148 </p>
1149 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
1150 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
1151 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
1152 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
1153 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
1154 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
1155 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://datatracker.ietf.org/doc/html/rfc2732">RFC 2732</a>, section 2:
1156 </p>
1157 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
1158 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
1159 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
1160 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
1161 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
1162 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
1163 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
1164 !! html/parsoid
1165 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php" class="external text">test</a></p>
1166
1167 <p>Examples from <a href="https://datatracker.ietf.org/doc/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
1168 <ul><li><a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]" class="external text">unicast</a></li>
1169 <li><a rel="mw:ExtLink" href="http://[FF01::101]" class="external text">multicast</a></li>
1170 <li><a rel="mw:ExtLink" href="http://[::1]/" class="external text">loopback</a></li>
1171 <li><a rel="mw:ExtLink" href="http://[::]" class="external text">unspecified</a></li>
1172 <li><a rel="mw:ExtLink" href="http://[::13.1.68.3]" class="external text">ipv4compat</a></li>
1173 <li><a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]" class="external text">ipv4compat</a></li></ul>
1174
1175 <p>Examples from <a href="https://datatracker.ietf.org/doc/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
1176 <ul><li><a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html" class="external text">1</a></li>
1177 <li><a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html" class="external text">2</a></li>
1178 <li><a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]" class="external text">3</a></li>
1179 <li><a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo" class="external text">4</a></li>
1180 <li><a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng" class="external text">5</a></li>
1181 <li><a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html" class="external text">6</a></li>
1182 <li><a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]" class="external text">7</a></li></ul>
1183 !! end
1184
1185 !! test
1186 Non-extlinks in brackets
1187 !! wikitext
1188 [foo]
1189 [foo bar]
1190 [foo ''bar'']
1191 [fool's] errand
1192 [fool's errand]
1193 [{{1x|foo}}]
1194 [{{1x|foo}} bar]
1195 [{{1x|foo}} ''bar'']
1196 [{{1x|foo}}l's] errand
1197 [{{1x|foo}}l's errand]
1198 [url={{1x|foo}}]
1199 [url=http://example.com]
1200 [http:// bare protocols don't count]
1201 !! html/php
1202 <p>[foo]
1203 [foo bar]
1204 [foo <i>bar</i>]
1205 [fool's] errand
1206 [fool's errand]
1207 [foo]
1208 [foo bar]
1209 [foo <i>bar</i>]
1210 [fool's] errand
1211 [fool's errand]
1212 [url=foo]
1213 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
1214 [http:// bare protocols don't count]
1215 </p>
1216 !! html/parsoid
1217 <p>[foo]
1218 [foo bar]
1219 [foo <i>bar</i>]
1220 [fool's] errand
1221 [fool's errand]
1222 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
1223 [<span about="#mwt20" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> bar]
1224 [<span about="#mwt21" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> <i>bar</i>]
1225 [<span about="#mwt22" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's] errand
1226 [<span about="#mwt23" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's errand]
1227 [url=<span about="#mwt24" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
1228 [url=<a rel="mw:ExtLink" href="http://example.com" class="external free">http://example.com</a>]
1229 [http:// bare protocols don't count]</p>
1230 !! end
1231
1232 !! test
1233 Percent encoding in external links
1234 !! wikitext
1235 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
1236 !! html/php
1237 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
1238 </p>
1239 !! html/parsoid
1240 <p><a rel="mw:ExtLink" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia" class="external text">Search</a></p>
1241 !! end
1242
1243 !! test
1244 Use url link syntax for links where the content is equal the link target
1245 !! wikitext
1246 http://example.com
1247 !! html/php
1248 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
1249 </p>
1250 !! html/parsoid
1251 <p><a rel="mw:ExtLink" href="http://example.com" class="external free">http://example.com</a></p>
1252 !! end
1253
1254 !! test
1255 Parenthesis in external links, especially URL links
1256 !! wikitext
1257 http://example.com)
1258
1259 http://example.com/test)
1260
1261 http://example.com/(test)
1262
1263 http://example.com/((test)
1264
1265 (http://example.com/(test))
1266
1267 (http://example.com/(test)))))
1268
1269 http://example.com/a)b
1270
1271 [http://example.com) foo]
1272 !! html/php
1273 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
1274 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
1275 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
1276 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
1277 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
1278 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
1279 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
1280 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
1281 </p>
1282 !! html/parsoid
1283 <p><a rel="mw:ExtLink" href="http://example.com" class="external free">http://example.com</a>)</p>
1284 <p><a rel="mw:ExtLink" href="http://example.com/test" class="external free">http://example.com/test</a>)</p>
1285 <p><a rel="mw:ExtLink" href="http://example.com/(test)" class="external free">http://example.com/(test)</a></p>
1286 <p><a rel="mw:ExtLink" href="http://example.com/((test)" class="external free">http://example.com/((test)</a></p>
1287 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))" class="external free">http://example.com/(test))</a></p>
1288 <p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))" class="external free">http://example.com/(test)))))</a></p>
1289 <p><a rel="mw:ExtLink" href="http://example.com/a)b" class="external free">http://example.com/a)b</a></p>
1290 <p><a rel="mw:ExtLink" href="http://example.com)" class="external text">foo</a></p>
1291 !! end
1292
1293 !! test
1294 Parenthesis in external links, w/ transclusion or comment
1295 !! wikitext
1296 (http://example.com/{{1x|hi}})
1297
1298 (http://example.com<!-- hi -->)
1299 !! html/php
1300 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
1301 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
1302 </p>
1303 !! html/parsoid
1304 <p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" href="http://example.com/hi" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/hi"},"sa":{"href":"http://example.com/{{1x|hi}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"http://example.com/&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}&#39;>hi&lt;/span>"}]]}'>http://example.com/hi</a>)</p>
1305
1306 <p>(<a rel="mw:ExtLink" href="http://example.com" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com"},"sa":{"href":"http://example.com&lt;!-- hi -->"}}'>http://example.com</a>)</p>
1307 !! end
1308
1309 ### Parsoid-specific tests
1310
1311 !! test
1312 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
1313 !! options
1314 parsoid=wt2wt
1315 !! wikitext
1316 [http://en.wikipedia.org/wiki/European_Robin European Robin]
1317 !! html/parsoid
1318 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
1319 !! end
1320
1321 !! test
1322 Parsoid extlink with _blank target
1323 !! options
1324 externallinktarget=_blank
1325 !! wikitext
1326 [https://www.example.com]
1327 !! html/parsoid
1328 <p><a rel="mw:ExtLink nofollow noreferrer noopener" href="https://www.example.com" class="external autonumber" target="_blank"></a></p>
1329 !! html/php
1330 <p><a target="_blank" rel="nofollow noreferrer noopener" class="external autonumber" href="https://www.example.com">[1]</a>
1331 </p>
1332 !! end
1333
1334 !! test
1335 Parsoid extlink with _self target
1336 !! options
1337 externallinktarget=_self
1338 !! wikitext
1339 [https://www.example.com]
1340 !! html/parsoid
1341 <p><a rel="mw:ExtLink nofollow" href="https://www.example.com" class="external autonumber" target="_self"></a></p>
1342 !! html/php
1343 <p><a target="_self" rel="nofollow" class="external autonumber" href="https://www.example.com">[1]</a>
1344 </p>
1345 !! end
1346
1347 !! test
1348 Extlink in square brackets with entity
1349 !! wikitext
1350 [&nbsp;[http://test.com 123]&nbsp;]
1351
1352 [http://test.com [123]
1353 !! html/php
1354 <p>[&#160;<a rel="nofollow" class="external text" href="http://test.com">123</a>&#160;]
1355 </p><p><a rel="nofollow" class="external text" href="http://test.com">[123</a>
1356 </p>
1357 !! html/parsoid
1358 <p>[<span typeof="mw:Entity"> </span><a rel="mw:ExtLink nofollow" href="http://test.com" class="external text">123</a><span typeof="mw:Entity"> </span>]</p>
1359
1360 <p><a rel="mw:ExtLink nofollow" href="http://test.com" class="external text">[123</a></p>
1361 !! end