Test case for disallowed character in an external link
[lhc/web/wiklou.git] / maintenance / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from http://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # ill add inter-language links
18 # subpage enable subpages (disabled by default)
19 # title=[[XXX]] run test using article title XXX
20 # disabled do not run test
21 #
22 # For testing purposes, temporary articles can created:
23 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
24 # where '/' denotes a newline.
25
26 # This is the standard article assumed to exist.
27 !! article
28 Main Page
29 !! text
30 blah blah
31 !! endarticle
32
33 ###
34 ### Basic tests
35 ###
36 !! test
37 Blank input
38 !! input
39 !! result
40 !! end
41
42
43 !! test
44 Simple paragraph
45 !! input
46 This is a simple paragraph.
47 !! result
48 <p>This is a simple paragraph.
49 </p>
50 !! end
51
52 !! test
53 Simple list
54 !! input
55 * Item 1
56 * Item 2
57 !! result
58 <ul><li> Item 1
59 </li><li> Item 2
60 </li></ul>
61
62 !! end
63
64 !! test
65 Italics and bold
66 !! input
67 * plain
68 * plain''italic''plain
69 * plain''italic''plain''italic''plain
70 * plain'''bold'''plain
71 * plain'''bold'''plain'''bold'''plain
72 * plain''italic''plain'''bold'''plain
73 * plain'''bold'''plain''italic''plain
74 * plain''italic'''bold-italic'''italic''plain
75 * plain'''bold''bold-italic''bold'''plain
76 * plain'''''bold-italic'''italic''plain
77 * plain'''''bold-italic''bold'''plain
78 * plain''italic'''bold-italic'''''plain
79 * plain'''bold''bold-italic'''''plain
80 * plain l'''italic''plain
81 !! result
82 <ul><li> plain
83 </li><li> plain<i>italic</i>plain
84 </li><li> plain<i>italic</i>plain<i>italic</i>plain
85 </li><li> plain<b>bold</b>plain
86 </li><li> plain<b>bold</b>plain<b>bold</b>plain
87 </li><li> plain<i>italic</i>plain<b>bold</b>plain
88 </li><li> plain<b>bold</b>plain<i>italic</i>plain
89 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
90 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
91 </li><li> plain<i><b>bold-italic</b>italic</i>plain
92 </li><li> plain<b><i>bold-italic</i>bold</b>plain
93 </li><li> plain<i>italic<b>bold-italic</b></i>plain
94 </li><li> plain<b>bold<i>bold-italic</i></b>plain
95 </li><li> plain l'<i>italic</i>plain
96 </li></ul>
97
98 !! end
99
100 ###
101 ### <nowiki> test cases
102 ###
103
104 !! test
105 <nowiki> unordered list
106 !! input
107 <nowiki>* This is not an unordered list item.</nowiki>
108 !! result
109 <p>* This is not an unordered list item.
110 </p>
111 !! end
112
113 !! test
114 <nowiki> spacing
115 !! input
116 <nowiki>Lorem ipsum dolor
117
118 sed abit.
119 sed nullum.
120
121 :and a colon
122 </nowiki>
123 !! result
124 <p>Lorem ipsum dolor
125
126 sed abit.
127 sed nullum.
128
129 :and a colon
130
131 </p>
132 !! end
133
134 !! test
135 nowiki 3
136 !! input
137 :There is not nowiki.
138 :There is <nowiki>nowiki</nowiki>.
139
140 #There is not nowiki.
141 #There is <nowiki>nowiki</nowiki>.
142
143 *There is not nowiki.
144 *There is <nowiki>nowiki</nowiki>.
145 !! result
146 <dl><dd>There is not nowiki.
147 </dd><dd>There is nowiki.
148 </dd></dl>
149 <ol><li>There is not nowiki.
150 </li><li>There is nowiki.
151 </li></ol>
152 <ul><li>There is not nowiki.
153 </li><li>There is nowiki.
154 </li></ul>
155
156 !! end
157
158 ###
159 ### comment test cases
160 ###
161 !! test
162 Comment test 1
163 !! input
164 <!-- comment 1 --> asdf
165 <!-- comment 2 -->
166 !! result
167 <pre>asdf
168 </pre>
169
170 !! end
171
172 !! test
173 Comment test 2
174 !! input
175 asdf
176 <!-- comment 1 -->
177 jkl
178 !! result
179 <p>asdf
180 jkl
181 </p>
182 !! end
183
184 !! test
185 Comment test 3
186 !! input
187 asdf
188 <!-- comment 1 -->
189 <!-- comment 2 -->
190 jkl
191 !! result
192 <p>asdf
193 jkl
194 </p>
195 !! end
196
197 !! test
198 Comment test 4
199 !! input
200 asdf<!-- comment 1 -->jkl
201 !! result
202 <p>asdfjkl
203 </p>
204 !! end
205
206 !! test
207 Comment spacing
208 !! input
209 a
210 <!-- foo --> b <!-- bar -->
211 c
212 !! result
213 <p>a
214 </p>
215 <pre> b
216 </pre>
217 <p>c
218 </p>
219 !! end
220
221 ###
222 ### Preformatted text
223 ###
224 !! test
225 Preformatted text
226 !! input
227 This is some
228 Preformatted text
229 With ''italic''
230 And '''bold'''
231 And a [[Main Page|link]]
232 !! result
233 <pre>This is some
234 Preformatted text
235 With <i>italic</i>
236 And <b>bold</b>
237 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
238 </pre>
239 !! end
240
241 ###
242 ### Definition list
243 ###
244 !! test
245 Simple definition
246 !! input
247 ; name : Definition
248 !! result
249 <dl><dt> name&nbsp;</dt><dd> Definition
250 </dd></dl>
251
252 !! end
253
254 !! test
255 Simple definition
256 !! input
257 : Indented text
258 !! result
259 <dl><dd> Indented text
260 </dd></dl>
261
262 !! end
263
264 !! test
265 Definition list with no space
266 !! input
267 ;name:Definition
268 !! result
269 <dl><dt>name</dt><dd>Definition
270 </dd></dl>
271
272 !!end
273
274 !! test
275 Definition list with URL link
276 !! input
277 ; http://example.com/ : definition
278 !! result
279 <dl><dt> <a href="http://example.com/" class='external'>http://example.com/</a>&nbsp;</dt><dd> definition
280 </dd></dl>
281
282 !! end
283
284 !! test
285 Definition list with bracketed URL link
286 !! input
287 ;[http://www.google.com/ Google]:Number one search engine
288 !! result
289 <dl><dt><a href="http://www.google.com/" class='external' title="http://www.google.com/">Google</a><span class='urlexpansion'> (<i>http://www.google.com/</i>)</span></dt><dd>Number one search engine
290 </dd></dl>
291
292 !! end
293
294 !! test
295 Definition list with wikilink containing colon
296 !! input
297 ; [[Wikipedia:FAQ]]: The least-read page on Wikipedia
298 !! result
299 <dl><dt> <a href="http://en.wikipedia.org/wiki/FAQ" class='extiw'>Wikipedia:FAQ</a></dt><dd> The least-read page on Wikipedia
300 </dd></dl>
301
302 !! end
303
304 # At Brion's and JeLuF's insistence... :)
305 !! test
306 Definition list with wikilink containing colon
307 !! input
308 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
309 !! result
310 <dl><dt> <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a></dt><dd> This isn't even a real newsgroup!
311 </dd></dl>
312
313 !! end
314
315 !! test
316 Malformed definition list with colon
317 !! input
318 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
319 !! result
320 <dl><dt> <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
321 </dt></dl>
322
323 !! end
324
325 !! test
326 Definition lists: colon in external link text
327 !! input
328 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
329 !! result
330 <dl><dt> <a href="http://www.wikipedia2.org/" class='external' title="http://www.wikipedia2.org/">Wikipedia&nbsp;: The Next Generation</a><span class='urlexpansion'> (<i>http://www.wikipedia2.org/</i>)</span></dt><dd> OK, I made that up
331 </dd></dl>
332
333 !! end
334
335
336 ###
337 ### External links
338 ###
339 !! test
340 External links: non-bracketed
341 !! input
342 Non-bracketed: http://example.com
343 !! result
344 <p>Non-bracketed: <a href="http://example.com" class='external'>http://example.com</a>
345 </p>
346 !! end
347
348 !! test
349 External links: numbered
350 !! input
351 Numbered: [http://example.com]
352 !! result
353 <p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
354 </p>
355 !!end
356
357 !! test
358 External links: specified text
359 !! input
360 Specified text: [http://example.com link]
361 !! result
362 <p>Specified text: <a href="http://example.com" class='external' title="http://example.com">link</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
363 </p>
364 !!end
365
366 !! test
367 External links: trail
368 !! input
369 Trail (not sure if this is meant to work): [http://example.com link]s
370 !! result
371 <p>Trail (not sure if this is meant to work): <a href="http://example.com" class='external' title="http://example.com">link</a>s<span class='urlexpansion'> (<i>http://example.com</i>)</span>
372 </p>
373 !! end
374
375 !! test
376 External links: dollar sign in URL
377 !! input
378 http://example.com/1$2345
379 !! result
380 <p><a href="http://example.com/1$2345" class='external'>http://example.com/1$2345</a>
381 </p>
382 !! end
383
384 !! test
385 External links: dollar sign in URL (named)
386 !! input
387 [http://example.com/1$2345]
388 !! result
389 <p><a href="http://example.com/1$2345" class='external' title="http://example.com/1$2345">[1]</a><span class='urlexpansion'> (<i>http://example.com/1$2345</i>)</span>
390 </p>
391 !!end
392
393 !! test
394 External image
395 !! input
396 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
397 !! result
398 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
399 </p>
400 !! end
401
402 !! test
403 External image from https
404 !! input
405 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
406 !! result
407 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
408 </p>
409 !! end
410
411 !! test
412 Link to non-http image, no img tag
413 !! input
414 Link to non-http image, no img tag: ftp://example.com/test.jpg
415 !! result
416 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a>
417 </p>
418 !! end
419
420 !! test
421 External links: terminating separator
422 !! input
423 Terminating separator: http://example.com/thing,
424 !! result
425 <p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,
426 </p>
427 !! end
428
429 !! test
430 External links: intervening separator
431 !! input
432 Intervening separator: http://example.com/1,2,3
433 !! result
434 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a>
435 </p>
436 !! end
437
438 !! test
439 External links: old bug with URL in query
440 !! input
441 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
442 !! result
443 <p>Old bug with URL in query: <a href="http://example.com/thing?url=http://example.com" class='external' title="http://example.com/thing?url=http://example.com">link</a><span class='urlexpansion'> (<i>http://example.com/thing?url=http://example.com</i>)</span>
444 </p>
445 !! end
446
447 !! test
448 External links: old URL-in-URL bug, mixed protocols
449 !! input
450 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
451 !! result
452 <p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external' title="ftp://example.com?url=http://example.com">link</a><span class='urlexpansion'> (<i>ftp://example.com?url=http://example.com</i>)</span>
453 </p>
454 !!end
455
456 !! test
457 External links: URL in text
458 !! input
459 URL in text: [http://example.com http://example.com]
460 !! result
461 <p>URL in text: <a href="http://example.com" class='external'>http://example.com</a>
462 </p>
463 !! end
464
465 !! test
466 External links: Clickable images
467 !! input
468 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
469 !! result
470 <p>ja-style clickable images: <a href="http://example.com" class='external' title="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
471 </p>
472 !!end
473
474 !! test
475 External links: raw ampersand
476 !! input
477 Old &amp; use: http://x&y
478 !! result
479 <p>Old &amp; use: <a href="http://x&amp;y" class='external'>http://x&amp;y</a>
480 </p>
481 !! end
482
483 !! test
484 External links: www.jpeg.org (bug 554)
485 !! input
486 http://www.jpeg.org
487 !!result
488 <p><a href="http://www.jpeg.org" class='external'>http://www.jpeg.org</a>
489 </p>
490 !! end
491
492 !! test
493 External links: URL within URL (original bug 2)
494 !! input
495 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
496 !! result
497 <p><a href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class='external' title="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a><span class='urlexpansion'> (<i>http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp</i>)</span>
498 </p>
499 !! end
500
501 !! test
502 BUG 361: URL inside bracketed URL
503 !! input
504 [http://www.example.com/foo http://www.example.com/bar]
505 !! result
506 <p><a href="http://www.example.com/foo" class='external' title="http://www.example.com/foo">http://www.example.com/bar</a><span class='urlexpansion'> (<i>http://www.example.com/foo</i>)</span>
507 </p>
508 !! end
509
510 !! test
511 BUG 289: ">"-token in URL-tail
512 !! input
513 http://www.example.com/<hello>
514 !! result
515 <p><a href="http://www.example.com/" class='external'>http://www.example.com/</a>&lt;hello&gt;
516 </p>
517 !!end
518
519 !! test
520 BUG 289: literal ">"-token in URL-tail
521 !! input
522 http://www.example.com/<b>html</b>
523 !! result
524 <p><a href="http://www.example.com/" class='external'>http://www.example.com/</a><b >html</b >
525 </p>
526 !!end
527
528 !! test
529 BUG 289: ">"-token in bracketed URL
530 !! input
531 [http://www.example.com/<hello> stuff]
532 !! result
533 <p><a href="http://www.example.com/" class='external' title="http://www.example.com/">&lt;hello&gt; stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
534 </p>
535 !!end
536
537 !! test
538 BUG 289: literal ">"-token in bracketed URL
539 !! input
540 [http://www.example.com/<b>html</b> stuff]
541 !! result
542 <p><a href="http://www.example.com/" class='external' title="http://www.example.com/"><b >html</b > stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
543 </p>
544 !!end
545
546 !! test
547 BUG 289: literal double quote at end of URL
548 !! input
549 http://www.example.com/"hello"
550 !! result
551 <p><a href="http://www.example.com/" class='external'>http://www.example.com/</a>"hello"
552 </p>
553 !!end
554
555 !! test
556 BUG 289: literal double quote in bracketed URL
557 !! input
558 [http://www.example.com/"hello" stuff]
559 !! result
560 <p><a href="http://www.example.com/" class='external' title="http://www.example.com/">"hello" stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
561 </p>
562 !!end
563
564 !! test
565 External links: invalid character
566 !! input
567 [http://www.example.com