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