Tests for bug 4781, 5267
[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 # noxml don't check for XML well formdness
20 # title=[[XXX]] run test using article title XXX
21 # disabled do not run test
22 #
23 # For testing purposes, temporary articles can created:
24 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
25 # where '/' denotes a newline.
26
27 # This is the standard article assumed to exist.
28 !! article
29 Main Page
30 !! text
31 blah blah
32 !! endarticle
33
34 ###
35 ### Basic tests
36 ###
37 !! test
38 Blank input
39 !! input
40 !! result
41 !! end
42
43
44 !! test
45 Simple paragraph
46 !! input
47 This is a simple paragraph.
48 !! result
49 <p>This is a simple paragraph.
50 </p>
51 !! end
52
53 !! test
54 Simple list
55 !! input
56 * Item 1
57 * Item 2
58 !! result
59 <ul><li> Item 1
60 </li><li> Item 2
61 </li></ul>
62
63 !! end
64
65 !! test
66 Italics and bold
67 !! input
68 * plain
69 * plain''italic''plain
70 * plain''italic''plain''italic''plain
71 * plain'''bold'''plain
72 * plain'''bold'''plain'''bold'''plain
73 * plain''italic''plain'''bold'''plain
74 * plain'''bold'''plain''italic''plain
75 * plain''italic'''bold-italic'''italic''plain
76 * plain'''bold''bold-italic''bold'''plain
77 * plain'''''bold-italic'''italic''plain
78 * plain'''''bold-italic''bold'''plain
79 * plain''italic'''bold-italic'''''plain
80 * plain'''bold''bold-italic'''''plain
81 * plain l'''italic''plain
82 !! result
83 <ul><li> plain
84 </li><li> plain<i>italic</i>plain
85 </li><li> plain<i>italic</i>plain<i>italic</i>plain
86 </li><li> plain<b>bold</b>plain
87 </li><li> plain<b>bold</b>plain<b>bold</b>plain
88 </li><li> plain<i>italic</i>plain<b>bold</b>plain
89 </li><li> plain<b>bold</b>plain<i>italic</i>plain
90 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
91 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
92 </li><li> plain<i><b>bold-italic</b>italic</i>plain
93 </li><li> plain<b><i>bold-italic</i>bold</b>plain
94 </li><li> plain<i>italic<b>bold-italic</b></i>plain
95 </li><li> plain<b>bold<i>bold-italic</i></b>plain
96 </li><li> plain l'<i>italic</i>plain
97 </li></ul>
98
99 !! end
100
101 ###
102 ### <nowiki> test cases
103 ###
104
105 !! test
106 <nowiki> unordered list
107 !! input
108 <nowiki>* This is not an unordered list item.</nowiki>
109 !! result
110 <p>* This is not an unordered list item.
111 </p>
112 !! end
113
114 !! test
115 <nowiki> spacing
116 !! input
117 <nowiki>Lorem ipsum dolor
118
119 sed abit.
120 sed nullum.
121
122 :and a colon
123 </nowiki>
124 !! result
125 <p>Lorem ipsum dolor
126
127 sed abit.
128 sed nullum.
129
130 :and a colon
131
132 </p>
133 !! end
134
135 !! test
136 nowiki 3
137 !! input
138 :There is not nowiki.
139 :There is <nowiki>nowiki</nowiki>.
140
141 #There is not nowiki.
142 #There is <nowiki>nowiki</nowiki>.
143
144 *There is not nowiki.
145 *There is <nowiki>nowiki</nowiki>.
146 !! result
147 <dl><dd>There is not nowiki.
148 </dd><dd>There is nowiki.
149 </dd></dl>
150 <ol><li>There is not nowiki.
151 </li><li>There is nowiki.
152 </li></ol>
153 <ul><li>There is not nowiki.
154 </li><li>There is nowiki.
155 </li></ul>
156
157 !! end
158
159 ###
160 ### Comments
161 ###
162 !! test
163 Comment test 1
164 !! input
165 <!-- comment 1 --> asdf
166 <!-- comment 2 -->
167 !! result
168 <pre>asdf
169 </pre>
170
171 !! end
172
173 !! test
174 Comment test 2
175 !! input
176 asdf
177 <!-- comment 1 -->
178 jkl
179 !! result
180 <p>asdf
181 jkl
182 </p>
183 !! end
184
185 !! test
186 Comment test 3
187 !! input
188 asdf
189 <!-- comment 1 -->
190 <!-- comment 2 -->
191 jkl
192 !! result
193 <p>asdf
194 jkl
195 </p>
196 !! end
197
198 !! test
199 Comment test 4
200 !! input
201 asdf<!-- comment 1 -->jkl
202 !! result
203 <p>asdfjkl
204 </p>
205 !! end
206
207 !! test
208 Comment spacing
209 !! input
210 a
211 <!-- foo --> b <!-- bar -->
212 c
213 !! result
214 <p>a
215 </p>
216 <pre> b
217 </pre>
218 <p>c
219 </p>
220 !! end
221
222 !! test
223 Comment whitespace
224 !! input
225 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
226 !! result
227
228 !! end
229
230 !! test
231 Comment semantics and delimiters
232 !! input
233 <!-- --><!----><!-----><!------>
234 !! result
235
236 !! end
237
238 !! test
239 Comment semantics and delimiters, redux
240 !! input
241 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
242 -- foo -- funky huh? ... -->
243 !! result
244
245 !! end
246
247 !! test
248 Comment semantics and delimiters: directors cut
249 !! input
250 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
251 everything starting with < followed by !-- until the first -- and > we see,
252 that wouldn't be valid XML however, since in XML -- has to terminate a comment
253 -->-->
254 !! result
255 <p>-->
256 </p>
257 !! end
258
259 !! test
260 Comment semantics: nesting
261 !! input
262 <!--<!-- no, we're not going to do anything fancy here -->-->
263 !! result
264 <p>-->
265 </p>
266 !! end
267
268
269 ###
270 ### Preformatted text
271 ###
272 !! test
273 Preformatted text
274 !! input
275 This is some
276 Preformatted text
277 With ''italic''
278 And '''bold'''
279 And a [[Main Page|link]]
280 !! result
281 <pre>This is some
282 Preformatted text
283 With <i>italic</i>
284 And <b>bold</b>
285 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
286 </pre>
287 !! end
288
289 ###
290 ### Definition lists
291 ###
292 !! test
293 Simple definition
294 !! input
295 ; name : Definition
296 !! result
297 <dl><dt> name&nbsp;</dt><dd> Definition
298 </dd></dl>
299
300 !! end
301
302 !! test
303 Simple definition
304 !! input
305 : Indented text
306 !! result
307 <dl><dd> Indented text
308 </dd></dl>
309
310 !! end
311
312 !! test
313 Definition list with no space
314 !! input
315 ;name:Definition
316 !! result
317 <dl><dt>name</dt><dd>Definition
318 </dd></dl>
319
320 !!end
321
322 !! test
323 Definition list with URL link
324 !! input
325 ; http://example.com/ : definition
326 !! result
327 <dl><dt> <a href="http://example.com/" class='external free' title="http://example.com/" rel="nofollow">http://example.com/</a>&nbsp;</dt><dd> definition
328 </dd></dl>
329
330 !! end
331
332 !! test
333 Definition list with bracketed URL link
334 !! input
335 ;[http://www.google.com/ Google]:Number one search engine
336 !! result
337 <dl><dt><a href="http://www.google.com/" class='external text' title="http://www.google.com/" rel="nofollow">Google</a></dt><dd>Number one search engine
338 </dd></dl>
339
340 !! end
341
342 !! test
343 Definition list with wikilink containing colon
344 !! input
345 ; [[Help:FAQ]]: The least-read page on Wikipedia
346 !! result
347 <dl><dt> <a href="/index.php?title=Help:FAQ&amp;action=edit" class="new" title="Help:FAQ">Help:FAQ</a></dt><dd> The least-read page on Wikipedia
348 </dd></dl>
349
350 !! end
351
352 # At Brion's and JeLuF's insistence... :)
353 !! test
354 Definition list with wikilink containing colon
355 !! input
356 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
357 !! result
358 <dl><dt> <a href="news:alt.wikipedia.rox" class='external free' title="news:alt.wikipedia.rox" rel="nofollow">news:alt.wikipedia.rox</a></dt><dd> This isn't even a real newsgroup!
359 </dd></dl>
360
361 !! end
362
363 !! test
364 Malformed definition list with colon
365 !! input
366 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
367 !! result
368 <dl><dt> <a href="news:alt.wikipedia.rox" class='external free' title="news:alt.wikipedia.rox" rel="nofollow">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
369 </dt></dl>
370
371 !! end
372
373 !! test
374 Definition lists: colon in external link text
375 !! input
376 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
377 !! result
378 <dl><dt> <a href="http://www.wikipedia2.org/" class='external text' title="http://www.wikipedia2.org/" rel="nofollow">Wikipedia&nbsp;: The Next Generation</a></dt><dd> OK, I made that up
379 </dd></dl>
380
381 !! end
382
383
384 ###
385 ### External links
386 ###
387 !! test
388 External links: non-bracketed
389 !! input
390 Non-bracketed: http://example.com
391 !! result
392 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
393 </p>
394 !! end
395
396 !! test
397 External links: numbered
398 !! input
399 Numbered: [http://example.com]
400 Numbered: [http://example.net]
401 Numbered: [http://example.org]
402 !! result
403 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
404 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
405 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
406 </p>
407 !!end
408
409 !! test
410 External links: specified text
411 !! input
412 Specified text: [http://example.com link]
413 !! result
414 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
415 </p>
416 !!end
417
418 !! test
419 External links: trail
420 !! input
421 Linktrails should not work for external links: [http://example.com link]s
422 !! result
423 <p>Linktrails should not work for external links: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>s
424 </p>
425 !! end
426
427 !! test
428 External links: dollar sign in URL
429 !! input
430 http://example.com/1$2345
431 !! result
432 <p><a href="http://example.com/1$2345" class='external free' title="http://example.com/1$2345" rel="nofollow">http://example.com/1$2345</a>
433 </p>
434 !! end
435
436 !! test
437 External links: dollar sign in URL (named)
438 !! input
439 [http://example.com/1$2345]
440 !! result
441 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
442 </p>
443 !!end
444
445 !! test
446 External links: open square bracket forbidden in URL (bug 4377)
447 !! input
448 http://example.com/1[2345
449 !! result
450 <p><a href="http://example.com/1" class='external free' title="http://example.com/1" rel="nofollow">http://example.com/1</a>[2345
451 </p>
452 !! end
453
454 !! test
455 External links: open square bracket forbidden in URL (named) (bug 4377)
456 !! input
457 [http://example.com/1[2345]
458 !! result
459 <p><a href="http://example.com/1" class='external text' title="http://example.com/1" rel="nofollow">[2345</a>
460 </p>
461 !!end
462
463 !! test
464 External image
465 !! input
466 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
467 !! result
468 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
469 </p>
470 !! end
471
472 !! test
473 External image from https
474 !! input
475 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
476 !! result
477 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
478 </p>
479 !! end
480
481 !! test
482 Link to non-http image, no img tag
483 !! input
484 Link to non-http image, no img tag: ftp://example.com/test.jpg
485 !! result
486 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external free' title="ftp://example.com/test.jpg" rel="nofollow">ftp://example.com/test.jpg</a>
487 </p>
488 !! end
489
490 !! test
491 External links: terminating separator
492 !! input
493 Terminating separator: http://example.com/thing,
494 !! result
495 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
496 </p>
497 !! end
498
499 !! test
500 External links: intervening separator
501 !! input
502 Intervening separator: http://example.com/1,2,3
503 !! result
504 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external free' title="http://example.com/1,2,3" rel="nofollow">http://example.com/1,2,3</a>
505 </p>
506 !! end
507
508 !! test
509 External links: old bug with URL in query
510 !! input
511 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
512 !! result
513 <p>Old bug with URL in query: <a href="http://example.com/thing?url=http://example.com" class='external text' title="http://example.com/thing?url=http://example.com" rel="nofollow">link</a>
514 </p>
515 !! end
516
517 !! test
518 External links: old URL-in-URL bug, mixed protocols
519 !! input
520 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
521 !! result
522 <p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external text' title="ftp://example.com?url=http://example.com" rel="nofollow">link</a>
523 </p>
524 !!end
525
526 !! test
527 External links: URL in text
528 !! input
529 URL in text: [http://example.com http://example.com]
530 !! result
531 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
532 </p>
533 !! end
534
535 !! test
536 External links: Clickable images
537 !! input
538 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
539 !! result
540 <p>ja-style clickable images: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
541 </p>
542 !!end
543
544 !! test
545 External links: raw ampersand
546 !! input
547 Old &amp; use: http://x&y
548 !! result
549 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
550 </p>
551 !! end
552
553 !! test
554 External links: encoded ampersand
555 !! input
556 Old &amp; use: http://x&amp;y
557 !! result
558 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
559 </p>
560 !! end
561
562 !! test
563 External links: [raw ampersand]
564 !! input
565 Old &amp; use: [http://x&y]
566 !! result
567 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
568 </p>
569 !! end
570
571 !! test
572 External links: [encoded ampersand]
573 !! input
574 Old &amp; use: [http://x&amp;y]
575 !! result
576 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
577 </p>
578 !! end
579
580 !! test
581 External links: www.jpeg.org (bug 554)
582 !! input
583 http://www.jpeg.org
584 !!result
585 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
586 </p>
587 !! end
588
589 !! test
590 External links: URL within URL (original bug 2)
591 !! input
592 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
593 !! result
594 <p><a href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class='external autonumber' title="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" rel="nofollow">[1]</a>
595 </p>
596 !! end
597
598 !! test
599 BUG 361: URL inside bracketed URL
600 !! input
601 [http://www.example.com/foo http://www.example.com/bar]
602 !! result
603 <p><a href="http://www.example.com/foo" class='external text' title="http://www.example.com/foo" rel="nofollow">http://www.example.com/bar</a>
604 </p>
605 !! end
606
607 !! test
608 BUG 361: URL within URL, not bracketed
609 !! input
610 http://www.example.com/foo?=http://www.example.com/bar
611 !! result
612 <p><a href="http://www.example.com/foo?=http://www.example.com/bar" class='external free' title="http://www.example.com/foo?=http://www.example.com/bar" rel="nofollow">http://www.example.com/foo?=http://www.example.com/bar</a>
613 </p>
614 !! end
615
616 !! test
617 BUG 289: ">"-token in URL-tail
618 !! input
619 http://www.example.com/<hello>
620 !! result
621 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>&lt;hello&gt;
622 </p>
623 !!end
624
625 !! test
626 BUG 289: literal ">"-token in URL-tail
627 !! input
628 http://www.example.com/<b>html</b>
629 !! result
630 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a><b>html</b>
631 </p>
632 !!end
633
634 !! test
635 BUG 289: ">"-token in bracketed URL
636 !! input
637 [http://www.example.com/<hello> stuff]
638 !! result
639 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
640 </p>
641 !!end
642
643 !! test
644 BUG 289: literal ">"-token in bracketed URL
645 !! input
646 [http://www.example.com/<b>html</b> stuff]
647 !! result
648 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
649 </p>
650 !!end
651
652 !! test
653 BUG 289: literal double quote at end of URL
654 !! input
655 http://www.example.com/"hello"
656 !! result
657 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
658 </p>
659 !!end
660
661 !! test
662 BUG 289: literal double quote in bracketed URL
663 !! input
664 [http://www.example.com/"hello" stuff]
665 !! result
666 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
667 </p>
668 !!end
669
670 !! test
671 External links: invalid character
672 !! input
673 [http://www.example.com test]
674 !! result
675 <p>[<a href="http://www.example.com" class='external free' title="http://www.example.com" rel="nofollow">http://www.example.com</a> test]
676 </p>
677 !! end
678
679 !! test
680 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (bug 5081)
681 !! input
682 [http://www.example.com test]
683 !! result
684 <p><a href="http://www.example.com" class='external text' title="http://www.example.com" rel="nofollow">test</a>
685 </p>
686 !! end
687
688 !! test
689 BUG 787: Links with one slash after the url protocol are invalid
690 !! input
691 http:/example.com
692
693 [http:/example.com title]
694 !! result
695 <p>http:/example.com
696 </p><p>[http:/example.com title]
697 </p>
698 !! end
699
700 !! test
701 Bug 2702: Mismatched <i> and <a> tags are invalid
702 !! input
703 ''[http://example.com text'']
704 !! result
705 <p><i><a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">text</a></i>
706 </p>
707 !! end
708
709
710 !! test
711 Bug 4781: %26 in URL
712 !! input
713 http://www.example.com/?title=AT%26T
714 !! result
715 <p><a href="http://www.example.com/?title=AT%26T" class='external free' title="http://www.example.com/?title=AT%26T" rel="nofollow">http://www.example.com/?title=AT%26T</a>
716 </p>
717 !! end
718
719 !! test
720 Bug 4781, 5267: %26 in URL
721 !! input
722 http://www.example.com/?title=100%25_Bran
723 !! result
724 <p><a href="http://www.example.com/?title=100%25_Bran" class='external free' title="http://www.example.com/?title=100%25_Bran" rel="nofollow">http://www.example.com/?title=100%25_Bran</a>
725 </p>
726 !! end
727
728 !! test
729 Bug 4781, 5267: %28, %29 in URL
730 !! input
731 http://www.example.com/?title=Ben-Hur_%281959_film%29
732 !! result
733 <p><a href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class='external free' title="http://www.example.com/?title=Ben-Hur_%281959_film%29" rel="nofollow">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
734 </p>
735 !! end
736
737
738 ###
739 ### Quotes
740 ###
741
742 !! test
743 Quotes
744 !! input
745 Normal text. '''Bold text.''' Normal text. ''Italic text.''
746
747 Normal text. '''''Bold italic text.''''' Normal text.
748 !!result
749 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
750 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
751 </p>
752 !! end
753
754
755 !! test
756 Unclosed and unmatched quotes
757 !! input
758 '''''Bold italic text '''with bold deactivated''' in between.'''''
759
760 '''''Bold italic text ''with italic deactivated'' in between.'''''
761
762 '''Bold text..
763
764 ..spanning two paragraphs (should not work).'''
765
766 '''Bold tag left open
767
768 ''Italic tag left open
769
770 Normal text.
771
772 <!-- Unmatching number of opening, closing tags: -->
773 '''This year''''s election ''should'' beat '''last year''''s.
774
775 ''Tom'''s car is bigger than ''Susan'''s.
776 !! result
777 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
778 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
779 </p><p><b>Bold text..</b>
780 </p><p>..spanning two paragraphs (should not work).<b></b>
781 </p><p><b>Bold tag left open</b>
782 </p><p><i>Italic tag left open</i>
783 </p><p>Normal text.
784 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
785 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
786 </p>
787 !! end
788
789 ###
790 ### Tables
791 ###
792 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
793 ###
794
795 # This should not produce <table></table> as <table><tr><td></td></tr></table>
796 # is the bare minimun required by the spec, see:
797 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
798 !! test
799 A table with no data.
800 !! input
801 {||}
802 !! result
803 !! end
804
805 # A table with nothing but a caption is invalid XHTML, we might want to render
806 # this as <p>caption</p>
807 !! test
808 A table with nothing but a caption
809 !! input
810 {|
811 |+ caption
812 |}
813 !! result
814 <table>
815 <caption> caption
816 </caption>
817 <tr>
818 <td>
819 </td></tr></table>
820 !! end
821
822 !! test
823 Simple table
824 !! input
825 {|
826 | 1 || 2
827 |-
828 | 3 || 4
829 |}
830 !! result
831 <table>
832 <tr>
833 <td> 1 </td><td> 2
834 </td></tr>
835 <tr>
836 <td> 3 </td><td> 4
837 </td></tr></table>
838
839 !! end
840
841 !! test
842 Multiplication table
843 !! input
844 {| border="1" cellpadding="2"
845 |+Multiplication table
846 |-
847 ! &times; !! 1 !! 2 !! 3
848 |-
849 ! 1
850 | 1 || 2 || 3
851 |-
852 ! 2
853 | 2 || 4 || 6
854 |-
855 ! 3
856 | 3 || 6 || 9
857 |-
858 ! 4
859 | 4 || 8 || 12
860 |-
861 ! 5
862 | 5 || 10 || 15
863 |}
864 !! result
865 <table border="1" cellpadding="2">
866 <caption>Multiplication table
867 </caption>
868 <tr>
869 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
870 </th></tr>
871 <tr>
872 <th> 1
873 </th><td> 1 </td><td> 2 </td><td> 3
874 </td></tr>
875 <tr>
876 <th> 2
877 </th><td> 2 </td><td> 4 </td><td> 6
878 </td></tr>
879 <tr>
880 <th> 3
881 </th><td> 3 </td><td> 6 </td><td> 9
882 </td></tr>
883 <tr>
884 <th> 4
885 </th><td> 4 </td><td> 8 </td><td> 12
886 </td></tr>
887 <tr>
888 <th> 5
889 </th><td> 5 </td><td> 10 </td><td> 15
890 </td></tr></table>
891
892 !! end
893
894 !! test
895 Table rowspan
896 !! input
897 {| align=right border=1
898 | Cell 1, row 1
899 |rowspan=2| Cell 2, row 1 (and 2)
900 | Cell 3, row 1
901 |-
902 | Cell 1, row 2
903 | Cell 3, row 2
904 |}
905 !! result
906 <table align="right" border="1">
907 <tr>
908 <td> Cell 1, row 1
909 </td><td rowspan="2"> Cell 2, row 1 (and 2)
910 </td><td> Cell 3, row 1
911 </td></tr>
912 <tr>
913 <td> Cell 1, row 2
914 </td><td> Cell 3, row 2
915 </td></tr></table>
916
917 !! end
918
919 !! test
920 Nested table
921 !! input
922 {| border=1
923 | &alpha;
924 |
925 {| bgcolor=#ABCDEF border=2
926 |nested
927 |-
928 |table
929 |}
930 |the original table again
931 |}
932 !! result
933 <table border="1">
934 <tr>
935 <td> &alpha;
936 </td><td>
937 <table bgcolor="#ABCDEF" border="2">
938 <tr>
939 <td>nested
940 </td></tr>
941 <tr>
942 <td>table
943 </td></tr></table>
944 </td><td>the original table again
945 </td></tr></table>
946
947 !! end
948
949 !! test
950 Invalid attributes in table cell (bug 1830)
951 !! input
952 {|
953 |Cell:|broken
954 |}
955 !! result
956 <table>
957 <tr>
958 <td>broken
959 </td></tr></table>
960
961 !! end
962
963
964 ###
965 ### Internal links
966 ###
967 !! test
968 Plain link, capitalized
969 !! input
970 [[Main Page]]
971 !! result
972 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
973 </p>
974 !! end
975
976 !! test
977 Plain link, uncapitalized
978 !! input
979 [[main Page]]
980 !! result
981 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
982 </p>
983 !! end
984
985 !! test
986 Piped link
987 !! input
988 [[Main Page|The Main Page]]
989 !! result
990 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
991 </p>
992 !! end
993
994 !! test
995 Broken link
996 !! input
997 [[Zigzagzogzagzig]]
998 !! result
999 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Link with prefix
1005 !! input
1006 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
1007 !! result
1008 <p>xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a>, xxx<a href="/wiki/Main_Page" title="Main Page">Main Page</a>, Xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a> XXX<a href="/wiki/Main_Page" title="Main Page">main Page</a>, XXX<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1009 </p>
1010 !! end
1011
1012 !! test
1013 Link with suffix
1014 !! input
1015 [[Main Page]]xxx, [[Main Page]]XXX
1016 !! result
1017 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
1018 </p>
1019 !! end
1020
1021 !! test
1022 Link with 3 brackets
1023 !! input
1024 [[[main page]]]
1025 !! result
1026 <p>[[[main page]]]
1027 </p>
1028 !! end
1029
1030 !! test
1031 Piped link with 3 brackets
1032 !! input
1033 [[[main page|the main page]]]
1034 !! result
1035 <p>[[[main page|the main page]]]
1036 </p>
1037 !! end
1038
1039 !! test
1040 Link with multiple pipes
1041 !! input
1042 [[Main Page|The|Main|Page]]
1043 !! result
1044 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
1045 </p>
1046 !! end
1047
1048 !! test
1049 Link to namespaces
1050 !! input
1051 [[Talk:Parser testing]], [[Meta:Disclaimers]]
1052 !! result
1053 <p><a href="/index.php?title=Talk:Parser_testing&amp;action=edit" class="new" title="Talk:Parser testing">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">Meta:Disclaimers</a>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Piped link to namespace
1059 !! input
1060 [[Meta:Disclaimers|The disclaimers]]
1061 !! result
1062 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
1063 </p>
1064 !! end
1065
1066 !! test
1067 Link containing }
1068 !! input
1069 [[Usually caused by a typo (oops}]]
1070 !! result
1071 <p>[[Usually caused by a typo (oops}]]
1072 </p>
1073 !! end
1074
1075 !! test
1076 Link containing % (not as a hex sequence)
1077 !! input
1078 [[7% Solution]]
1079 !! result
1080 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1081 </p>
1082 !! end
1083
1084 !! test
1085 Link containing % as a single hex sequence interpreted to char
1086 !! input
1087 [[7%25 Solution]]
1088 !! result
1089 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1090 </p>
1091 !!end
1092
1093 !! test
1094 Link containing % as a double hex sequence interpreted to hex sequence
1095 !! input
1096 [[7%2525 Solution]]
1097 !! result
1098 <p>[[7%2525 Solution]]
1099 </p>
1100 !!end
1101
1102 !! test
1103 Link containing "#<" and "#>" % as a hex sequences
1104 !! input
1105 [[%23%3c]]<!-- Render this as "[[#%3c]]" maybe.. ? -->[[%23%3e]]<!-- ..."[[#%3e]]" ? -->
1106 !! result
1107 <p>[[%23%3c]][[%23%3e]]
1108 </p>
1109 !! end
1110
1111 !! test
1112 Link containing "<#" and ">#" as a hex sequences
1113 !! input
1114 [[%3c%23]][[%3e%23]]
1115 !! result
1116 <p>[[%3c%23]][[%3e%23]]
1117 </p>
1118 !! end
1119
1120 !! test
1121 Plain link to URL
1122 !! input
1123 [[http://www.example.org]]
1124 !! result
1125 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1126 </p>
1127 !! end
1128
1129 # I'm fairly sure the expected result here is wrong.
1130 # We want these to be URL links, not pseudo-pages with URLs for titles....
1131 # However the current output is also pretty screwy.
1132 #
1133 # ----
1134 # I'm changing it to match the current output--it arguably makes more
1135 # sense in the light of the test above. Old expected result was:
1136 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.org&amp;action=edit" class="new" title="Http://www.example.org">an example URL</a>
1137 #</p>
1138 # But I think this test is bordering on "garbage in, garbage out" anyway.
1139 # -- wtm
1140 !! test
1141 Piped link to URL
1142 !! input
1143 Piped link to URL: [[http://www.example.org|an example URL]]
1144 !! result
1145 <p>Piped link to URL: [<a href="http://www.example.org|an" class='external text' title="http://www.example.org|an" rel="nofollow">example URL</a>]
1146 </p>
1147 !! end
1148
1149 !! test
1150 BUG 2: [[page|http://url/]] should link to page, not http://url/
1151 !! input
1152 [[Main Page|http://url/]]
1153 !! result
1154 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1155 </p>
1156 !! end
1157
1158 !! test
1159 BUG 337: Escaped self-links should be bold
1160 !! options
1161 title=[[Bug462]]
1162 !! input
1163 [[Bu&#103;462]] [[Bug462]]
1164 !! result
1165 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1166 </p>
1167 !! end
1168
1169 !! test
1170 Self-link to section should not be bold
1171 !! options
1172 title=[[Main Page]]
1173 !! input
1174 [[Main Page#section]]
1175 !! result
1176 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1177 </p>
1178 !! end
1179
1180 !! test
1181 <nowiki> inside a link
1182 !! input
1183 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1184 !! result
1185 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
1186 </p>
1187 !! end
1188
1189 ###
1190 ### Interwiki links (see maintenance/interwiki.sql)
1191 ###
1192
1193 !! test
1194 Inline interwiki link
1195 !! input
1196 [[MeatBall:SoftSecurity]]
1197 !! result
1198 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
1199 </p>
1200 !! end
1201
1202 !! test
1203 Inline interwiki link with empty title (bug 2372)
1204 !! input
1205 [[MeatBall:]]
1206 !! result
1207 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="meatball:">MeatBall:</a>
1208 </p>
1209 !! end
1210
1211 !! test
1212 Interwiki link encoding conversion (bug 1636)
1213 !! input
1214 *[[Wikipedia:ro:Olteni&#0355;a]]
1215 *[[Wikipedia:ro:Olteni&#355;a]]
1216 !! result
1217 <ul><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class='extiw' title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
1218 </li><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class='extiw' title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
1219 </li></ul>
1220
1221 !! end
1222
1223 !! test
1224 Interwiki link with fragment (bug 2130)
1225 !! input
1226 [[MeatBall:SoftSecurity#foo]]
1227 !! result
1228 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1229 </p>
1230 !! end
1231
1232 ##
1233 ## XHTML tidiness
1234 ###
1235
1236 !! test
1237 <br> to <br />
1238 !! input
1239 1<br>2<br />3
1240 !! result
1241 <p>1<br />2<br />3
1242 </p>
1243 !! end
1244
1245 !! test
1246 Incorrecly removing closing slashes from correctly formed XHTML
1247 !! input
1248 <br style="clear:both;" />
1249 !! result
1250 <p><br style="clear:both;" />
1251 </p>
1252 !! end
1253
1254 !! test
1255 Failing to transform badly formed HTML into correct XHTML
1256 !! input
1257 <br clear=left>
1258 <br clear=right>
1259 <br clear=all>
1260 !! result
1261 <p><br clear="left" />
1262 <br clear="right" />
1263 <br clear="all" />
1264 </p>
1265 !!end
1266
1267 !! test
1268 Horizontal ruler (should it add that extra space?)
1269 !! input
1270 <hr>
1271 <hr >
1272 foo <hr
1273 > bar
1274 !! result
1275 <hr />
1276 <hr />
1277 foo <hr /> bar
1278
1279 !! end
1280
1281 ###
1282 ### Block-level elements
1283 ###
1284 !! test
1285 Common list
1286 !! input
1287 *Common list
1288 * item 2
1289 *item 3
1290 !! result
1291 <ul><li>Common list
1292 </li><li> item 2
1293 </li><li>item 3
1294 </li></ul>
1295
1296 !! end
1297
1298 !! test
1299 Numbered list
1300 !! input
1301 #Numbered list
1302 #item 2
1303 # item 3
1304 !! result
1305 <ol><li>Numbered list
1306 </li><li>item 2
1307 </li><li> item 3
1308 </li></ol>
1309
1310 !! end
1311
1312 !! test
1313 Mixed list
1314 !! input
1315 *Mixed list
1316 *# with numbers
1317 ** and bullets
1318 *# and numbers
1319 *bullets again
1320 **bullet level 2
1321 ***bullet level 3
1322 ***#Number on level 4
1323 **bullet level 2
1324 **#Number on level 3
1325 **#Number on level 3
1326 *#number level 2
1327 *Level 1
1328 !! result
1329 <ul><li>Mixed list
1330 <ol><li> with numbers
1331 </li></ol>
1332 <ul><li> and bullets
1333 </li></ul>
1334 <ol><li> and numbers
1335 </li></ol>
1336 </li><li>bullets again
1337 <ul><li>bullet level 2
1338 <ul><li>bullet level 3
1339 <ol><li>Number on level 4
1340 </li></ol>
1341 </li></ul>
1342 </li><li>bullet level 2
1343 <ol><li>Number on level 3
1344 </li><li>Number on level 3
1345 </li></ol>
1346 </li></ul>
1347 <ol><li>number level 2
1348 </li></ol>
1349 </li><li>Level 1
1350 </li></ul>
1351
1352 !! end
1353
1354 !! test
1355 List items are not parsed correctly following a <pre> block (bug 785)
1356 !! input
1357 * <pre>foo</pre>
1358 * <pre>bar</pre>
1359 * zar
1360 !! result
1361 <ul><li> <pre>foo</pre>
1362 </li><li> <pre>bar</pre>
1363 </li><li> zar
1364 </li></ul>
1365
1366 !! end
1367
1368 ###
1369 ### Magic Words
1370 ###
1371
1372 !! test
1373 Magic Word: {{CURRENTDAY}}
1374 !! input
1375 {{CURRENTDAY}}
1376 !! result
1377 <p>1
1378 </p>
1379 !! end
1380
1381 !! test
1382 Magic Word: {{CURRENTDAY2}}
1383 !! input
1384 {{CURRENTDAY2}}
1385 !! result
1386 <p>01
1387 </p>
1388 !! end
1389
1390 !! test
1391 Magic Word: {{CURRENTDAYNAME}}
1392 !! input
1393 {{CURRENTDAYNAME}}
1394 !! result
1395 <p>Thursday
1396 </p>
1397 !! end
1398
1399 !! test
1400 Magic Word: {{CURRENTDOW}}
1401 !! input
1402 {{CURRENTDOW}}
1403 !! result
1404 <p>4
1405 </p>
1406 !! end
1407
1408 !! test
1409 Magic Word: {{CURRENTMONTH}}
1410 !! input
1411 {{CURRENTMONTH}}
1412 !! result
1413 <p>01
1414 </p>
1415 !! end
1416
1417 !! test
1418 Magic Word: {{CURRENTMONTHABBREV}}
1419 !! input
1420 {{CURRENTMONTHABBREV}}
1421 !! result
1422 <p>Jan
1423 </p>
1424 !! end
1425
1426 !! test
1427 Magic Word: {{CURRENTMONTHNAME}}
1428 !! input
1429 {{CURRENTMONTHNAME}}
1430 !! result
1431 <p>January
1432 </p>
1433 !! end
1434
1435 !! test
1436 Magic Word: {{CURRENTMONTHNAMEGEN}}
1437 !! input
1438 {{CURRENTMONTHNAMEGEN}}
1439 !! result
1440 <p>January
1441 </p>
1442 !! end
1443
1444 !! test
1445 Magic Word: {{CURRENTTIME}}
1446 !! input
1447 {{CURRENTTIME}}
1448 !! result
1449 <p>00:02
1450 </p>
1451 !! end
1452
1453 !! test
1454 Magic Word: {{CURRENTWEEK}} (@bug 4594)
1455 !! input
1456 {{CURRENTWEEK}}
1457 !! result
1458 <p>1
1459 </p>
1460 !! end
1461
1462 !! test
1463 Magic Word: {{CURRENTYEAR}}
1464 !! input
1465 {{CURRENTYEAR}}
1466 !! result
1467 <p>1970
1468 </p>
1469 !! end
1470
1471 !! test
1472 Magic Word: {{FULLPAGENAME}}
1473 !! options
1474 title=[[User:Ævar Arnfjörð Bjarmason]]
1475 !! input
1476 {{FULLPAGENAME}}
1477 !! result
1478 <p>User:Ævar Arnfjörð Bjarmason
1479 </p>
1480 !! end
1481
1482 !! test
1483 Magic Word: {{FULLPAGENAMEE}}
1484 !! options
1485 title=[[User:Ævar Arnfjörð Bjarmason]]
1486 !! input
1487 {{FULLPAGENAMEE}}
1488 !! result
1489 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1490 </p>
1491 !! end
1492
1493 !! test
1494 Magic Word: {{NAMESPACE}}
1495 !! options
1496 title=[[User:Ævar Arnfjörð Bjarmason]]
1497 disabled # FIXME
1498 !! input
1499 {{NAMESPACE}}
1500 !! result
1501 <p>User
1502 </p>
1503 !! end
1504
1505 !! test
1506 Magic Word: {{NAMESPACEE}}
1507 !! options
1508 title=[[User:Ævar Arnfjörð Bjarmason]]
1509 disabled # FIXME
1510 !! input
1511 {{NAMESPACEE}}
1512 !! result
1513 <p>User
1514 </p>
1515 !! end
1516
1517 !! test
1518 Magic Word: {{NUMBEROFARTICLES}}
1519 !! input
1520 {{NUMBEROFARTICLES}}
1521 !! result
1522 <p>-1
1523 </p>
1524 !! end
1525
1526 !! test
1527 Magic Word: {{NUMBEROFFILES}}
1528 !! input
1529 {{NUMBEROFFILES}}
1530 !! result
1531 <p>1
1532 </p>
1533 !! end
1534
1535 !! test
1536 Magic Word: {{PAGENAME}}
1537 !! options
1538 title=[[User:Ævar Arnfjörð Bjarmason]]
1539 disabled # FIXME
1540 !! input
1541 {{PAGENAME}}
1542 !! result
1543 <p>Ævar Arnfjörð Bjarmason
1544 </p>
1545 !! end
1546
1547 !! test
1548 Magic Word: {{PAGENAMEE}}
1549 !! options
1550 title=[[User:Ævar Arnfjörð Bjarmason]]
1551 !! input
1552 {{PAGENAMEE}}
1553 !! result
1554 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1555 </p>
1556 !! end
1557
1558 !! test
1559 Magic Word: {{REVISIONID}}
1560 !! input
1561 {{REVISIONID}}
1562 !! result
1563 <p>1337
1564 </p>
1565 !! end
1566
1567 !! test
1568 Magic Word: {{SCRIPTPATH}}
1569 !! input
1570 {{SCRIPTPATH}}
1571 !! result
1572 <p>/
1573 </p>
1574 !! end
1575
1576 !! test
1577 Magic Word: {{SERVER}}
1578 !! input
1579 {{SERVER}}
1580 !! result
1581 <p><a href="http://localhost" class='external free' title="http://localhost" rel="nofollow">http://localhost</a>
1582 </p>
1583 !! end
1584
1585 !! test
1586 Magic Word: {{SERVERNAME}}
1587 !! input
1588 {{SERVERNAME}}
1589 !! result
1590 <p>Britney Spears
1591 </p>
1592 !! end
1593
1594 !! test
1595 Magic Word: {{SITENAME}}
1596 !! input
1597 {{SITENAME}}
1598 !! result
1599 <p>MediaWiki
1600 </p>
1601 !! end
1602
1603 !! test
1604 Namespace 1 {{ns:1}}
1605 !! input
1606 {{ns:1}}
1607 !! result
1608 <p>Talk
1609 </p>
1610 !! end
1611
1612 !! test
1613 Namespace 1 {{ns:01}}
1614 !! input
1615 {{ns:01}}
1616 !! result
1617 <p>Talk
1618 </p>
1619 !! end
1620
1621 !! test
1622 Namespace 0 {{ns:0}} (bug 4783)
1623 !! input
1624 {{ns:0}}
1625 !! result
1626
1627 !! end
1628
1629 !! test
1630 Namespace 0 {{ns:00}} (bug 4783)
1631 !! input
1632 {{ns:00}}
1633 !! result
1634
1635 !! end
1636
1637 !! test
1638 Namespace -1 {{ns:-1}}
1639 !! input
1640 {{ns:-1}}
1641 !! result
1642 <p>Special
1643 </p>
1644 !! end
1645
1646 !! test
1647 Namespace Project {{ns:User}}
1648 !! input
1649 {{ns:User}}
1650 !! result
1651 <p>User
1652 </p>
1653 !! end
1654
1655
1656 ###
1657 ### Magic links
1658 ###
1659 !! test
1660 Magic links: internal link to RFC (bug 479)
1661 !! input
1662 [[RFC 123]]
1663 !! result
1664 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1665 </p>
1666 !! end
1667
1668 !! test
1669 Magic links: RFC (bug 479)
1670 !! input
1671 RFC 822
1672 !! result
1673 <p><a href='http://www.ietf.org/rfc/rfc822.txt' class='external' title="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>
1674 </p>
1675 !! end
1676
1677 !! test
1678 Magic links: ISBN (bug 1937)
1679 !! input
1680 ISBN 0-306-40615-2
1681 !! result
1682 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1683 </p>
1684 !! end
1685
1686 !! test
1687 Magic links: PMID incorrectly converts space to underscore
1688 !! input
1689 PMID 1234
1690 !! result
1691 <p><a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=1234' class='external' title="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=1234">PMID 1234</a>
1692 </p>
1693 !! end
1694
1695 ###
1696 ### Templates
1697 ####
1698
1699 !! test
1700 Nonexistant template
1701 !! input
1702 {{thistemplatedoesnotexist}}
1703 !! result
1704 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1705 </p>
1706 !! end
1707
1708 !! article
1709 Template:test
1710 !! text
1711 This is a test template
1712 !! endarticle
1713
1714 !! test
1715 Simple template
1716 !! input
1717 {{test}}
1718 !! result
1719 <p>This is a test template
1720 </p>
1721 !! end
1722
1723 !! test
1724 Template with explicit namespace
1725 !! input
1726 {{Template:test}}
1727 !! result
1728 <p>This is a test template
1729 </p>
1730 !! end
1731
1732
1733 !! article
1734 Template:paramtest
1735 !! text
1736 This is a test template with parameter {{{param}}}
1737 !! endarticle
1738
1739 !! test
1740 Template parameter
1741 !! input
1742 {{paramtest|param=foo}}
1743 !! result
1744 <p>This is a test template with parameter foo
1745 </p>
1746 !! end
1747
1748 !! article
1749 Template:paramtestnum
1750 !! text
1751 [[{{{1}}}|{{{2}}}]]
1752 !! endarticle
1753
1754 !! test
1755 Template unnamed parameter
1756 !! input
1757 {{paramtestnum|Main Page|the main page}}
1758 !! result
1759 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1760 </p>
1761 !! end
1762
1763 !! article
1764 Template:templatesimple
1765 !! text
1766 (test)
1767 !! endarticle
1768
1769 !! article
1770 Template:templateredirect
1771 !! text
1772 #redirect [[Template:templatesimple]]
1773 !! endarticle
1774
1775 !! article
1776 Template:templateasargtestnum
1777 !! text
1778 {{{{{1}}}}}
1779 !! endarticle
1780
1781 !! article
1782 Template:templateasargtest
1783 !! text
1784 {{template{{{templ}}}}}
1785 !! endarticle
1786
1787 !! article
1788 Template:templateasargtest2
1789 !! text
1790 {{{{{templ}}}}}
1791 !! endarticle
1792
1793 !! test
1794 Template with template name as unnamed argument
1795 !! input
1796 {{templateasargtestnum|templatesimple}}
1797 !! result
1798 <p>(test)
1799 </p>
1800 !! end
1801
1802 !! test
1803 Template with template name as argument
1804 !! input
1805 {{templateasargtest|templ=simple}}
1806 !! result
1807 <p>(test)
1808 </p>
1809 !! end
1810
1811 !! test
1812 Template with template name as argument (2)
1813 !! input
1814 {{templateasargtest2|templ=templatesimple}}
1815 !! result
1816 <p>(test)
1817 </p>
1818 !! end
1819
1820 !! article
1821 Template:templateasargtestdefault
1822 !! text
1823 {{{{{templ|templatesimple}}}}}
1824 !! endarticle
1825
1826 !! article
1827 Template:templa
1828 !! text
1829 '''templ'''
1830 !! endarticle
1831
1832 !! test
1833 Template with default value
1834 !! input
1835 {{templateasargtestdefault}}
1836 !! result
1837 <p>(test)
1838 </p>
1839 !! end
1840
1841 !! test
1842 Template with default value (value set)
1843 !! input
1844 {{templateasargtestdefault|templ=templa}}
1845 !! result
1846 <p><b>templ</b>
1847 </p>
1848 !! end
1849
1850 !! test
1851 Template redirect
1852 !! input
1853 {{templateredirect}}
1854 !! result
1855 <p>(test)
1856 </p>
1857 !! end
1858
1859 !! test
1860 Template with argument in separate line
1861 !! input
1862 {{ templateasargtest |
1863 templ = simple }}
1864 !! result
1865 <p>(test)
1866 </p>
1867 !! end
1868
1869 !! test
1870 Template with complex template as argument
1871 !! input
1872 {{paramtest|
1873 param ={{ templateasargtest |
1874 templ = simple }}}}
1875 !! result
1876 <p>This is a test template with parameter (test)
1877 </p>
1878 !! end
1879
1880 !! test
1881 Template with thumb image (wiht link in description)
1882 !! input
1883 {{paramtest|
1884 param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
1885 !! result
1886 This is a test template with parameter <div class="thumb tright"><div style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="Image:Noimage.png">Image:Noimage.png</a> <div class="thumbcaption" ><a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">link</a> <a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">caption</a></div></div></div>
1887
1888 !! end
1889
1890 !! article
1891 Template:complextemplate
1892 !! text
1893 {{{1}}} {{paramtest|
1894 param ={{{param}}}}}
1895 !! endarticle
1896
1897 !! test
1898 Template with complex arguments
1899 !! input
1900 {{complextemplate|
1901 param ={{ templateasargtest |
1902 templ = simple }}|[[Template:complextemplate|link]]}}
1903 !! result
1904 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
1905 </p>
1906 !! end
1907
1908 !! test
1909 BUG 553: link with two variables in a piped link
1910 !! input
1911 {|
1912 |[[{{{1}}}|{{{2}}}]]
1913 |}
1914 !! result
1915 <table>
1916 <tr>
1917 <td>[[{{{1}}}|{{{2}}}]]
1918 </td></tr></table>
1919
1920 !! end
1921
1922 !! test
1923 Magic variable as template parameter
1924 !! input
1925 {{paramtest|param={{SITENAME}}}}
1926 !! result
1927 <p>This is a test template with parameter MediaWiki
1928 </p>
1929 !! end
1930
1931 !! article
1932 Template:linktest
1933 !! text
1934 [[{{{param}}}|link]]
1935 !! endarticle
1936
1937 !! test
1938 Template parameter as link source
1939 !! input
1940 {{linktest|param=Main Page}}
1941 !! result
1942 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1943 </p>
1944 !! end
1945
1946
1947 !!article
1948 Template:paramtest2
1949 !! text
1950 including another template, {{paramtest|param={{{arg}}}}}
1951 !! endarticle
1952
1953 !! test
1954 Template passing argument to another template
1955 !! input
1956 {{paramtest2|arg='hmm'}}
1957 !! result
1958 <p>including another template, This is a test template with parameter 'hmm'
1959 </p>
1960 !! end
1961
1962 !! article
1963 Template:Linktest2
1964 !! text
1965 Main Page
1966 !! endarticle
1967
1968 !! test
1969 Template as link source
1970 !! input
1971 [[{{linktest2}}]]
1972 !! result
1973 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1974 </p>
1975 !! end
1976
1977
1978 !! article
1979 Template:loop1
1980 !! text
1981 {{loop2}}
1982 !! endarticle
1983
1984 !! article
1985 Template:loop2
1986 !! text
1987 {{loop1}}
1988 !! endarticle
1989
1990 !! test
1991 Template infinite loop
1992 !! input
1993 {{loop1}}
1994 !! result
1995 <p>{{loop1}}<!-- WARNING: template loop detected -->
1996 </p>
1997 !! end
1998
1999 !! test
2000 Template from main namespace
2001 !! input
2002 {{:Main Page}}
2003 !! result
2004 <p>blah blah
2005 </p>
2006 !! end
2007
2008 !! article
2009 Template:table
2010 !! text
2011 {|
2012 | 1 || 2
2013 |-
2014 | 3 || 4
2015 |}
2016 !! endarticle
2017
2018 !! test
2019 BUG 529: Template with table, not included at beginning of line
2020 !! input
2021 foo {{table}}
2022 !! result
2023 <p>foo
2024 </p>
2025 <table>
2026 <tr>
2027 <td> 1 </td><td> 2
2028 </td></tr>
2029 <tr>
2030 <td> 3 </td><td> 4
2031 </td></tr></table>
2032
2033 !! end
2034
2035 !! test
2036 BUG 523: Template shouldn't eat newline (or add an extra one before table)
2037 !! input
2038 foo
2039 {{table}}
2040 !! result
2041 <p>foo
2042 </p>
2043 <table>
2044 <tr>
2045 <td> 1 </td><td> 2
2046 </td></tr>
2047 <tr>
2048 <td> 3 </td><td> 4
2049 </td></tr></table>
2050
2051 !! end
2052
2053 !! test
2054 BUG 41: Template parameters shown as broken links
2055 !! input
2056 {{{parameter}}}
2057 !! result
2058 <p>{{{parameter}}}
2059 </p>
2060 !! end
2061
2062
2063 !! article
2064 Template:MSGNW test
2065 !! text
2066 ''None'' of '''this''' should be
2067 * interepreted
2068 but rather passed unmodified
2069 {{test}}
2070 !! endarticle
2071
2072 # hmm, fix this or just deprecate msgnw and document its behavior?
2073 !! test
2074 msgnw keyword
2075 !! options
2076 disabled
2077 !! input
2078 {{msgnw:MSGNW test}}
2079 !! result
2080 <p>''None'' of '''this''' should be
2081 * interepreted
2082 but rather passed unmodified
2083 {{test}}
2084 </p>
2085 !! end
2086
2087 !! test
2088 int keyword
2089 !! input
2090 {{int:youhavenewmessages|lots of money|not!}}
2091 !! result
2092 <p>You have lots of money (not!).
2093 </p>
2094 !! end
2095
2096 !! article
2097 Template:Includes
2098 !! text
2099 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2100 !! endarticle
2101
2102 !! test
2103 <includeonly> and <noinclude> being included
2104 !! input
2105 {{Includes}}
2106 !! result
2107 <p>Foobar
2108 </p>
2109 !! end
2110
2111 !! article
2112 Template:Includes2
2113 !! text
2114 <onlyinclude>Foo</onlyinclude>bar
2115 !! endarticle
2116
2117 !! test
2118 <onlyinclude> being included
2119 !! input
2120 {{Includes2}}
2121 !! result
2122 <p>Foo
2123 </p>
2124 !! end
2125
2126
2127 !! article
2128 Template:Includes3
2129 !! text
2130 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
2131 !! endarticle
2132
2133 !! test
2134 <onlyinclude> and <includeonly> being included
2135 !! input
2136 {{Includes3}}
2137 !! result
2138 <p>Foo
2139 </p>
2140 !! end
2141
2142 !! test
2143 <includeonly> and <noinclude> on a page
2144 !! input
2145 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2146 !! result
2147 <p>Foozar
2148 </p>
2149 !! end
2150
2151 !! test
2152 <onlyinclude> on a page
2153 !! input
2154 <onlyinclude>Foo</onlyinclude>bar
2155 !! result
2156 <p>Foobar
2157 </p>
2158 !! end
2159
2160 ###
2161 ### Pre-save transform tests
2162 ###
2163 !! test
2164 pre-save transform: subst:
2165 !! options
2166 PST
2167 !! input
2168 {{subst:test}}
2169 !! result
2170 This is a test template
2171 !! end
2172
2173 !! test
2174 pre-save transform: normal template
2175 !! options
2176 PST
2177 !! input
2178 {{test}}
2179 !! result
2180 {{test}}
2181 !! end
2182
2183 !! test
2184 pre-save transform: nonexistant template
2185 !! options
2186 PST
2187 !! input
2188 {{thistemplatedoesnotexist}}
2189 !! result
2190 {{thistemplatedoesnotexist}}
2191 !! end
2192
2193
2194 !! test
2195 pre-save transform: subst magic variables
2196 !! options
2197 PST
2198 !! input
2199 {{subst:SITENAME}}
2200 !! result
2201 MediaWiki
2202 !! end
2203
2204 # This is bug 89, which I fixed. -- wtm
2205 !! test
2206 pre-save transform: subst: templates with parameters
2207 !! options
2208 pst
2209 !! input
2210 {{subst:paramtest|param="something else"}}
2211 !! result
2212 This is a test template with parameter "something else"
2213 !! end
2214
2215 !! article
2216 Template:nowikitest
2217 !! text
2218 <nowiki>'''not wiki'''</nowiki>
2219 !! endarticle
2220
2221 !! test
2222 pre-save transform: nowiki in subst (bug 1188)
2223 !! options
2224 pst
2225 !! input
2226 {{subst:nowikitest}}
2227 !! result
2228 <nowiki>'''not wiki'''</nowiki>
2229 !! end
2230
2231
2232 !! article
2233 Template:commenttest
2234 !! text
2235 This template has <!-- a comment --> in it.
2236 !! endarticle
2237
2238 !! test
2239 pre-save transform: comment in subst (bug 1936)
2240 !! options
2241 pst
2242 !! input
2243 {{subst:commenttest}}
2244 !! result
2245 This template has <!-- a comment --> in it.
2246 !! end
2247
2248
2249 !! article
2250 Template:dangerous
2251 !!text
2252 <span onmouseover="alert('crap')">Oh no</span>
2253 !!endarticle
2254
2255 !!test
2256 (confirming safety of fix for subst bug 1936)
2257 !! input
2258 {{Template:dangerous}}
2259 !! result
2260 <p><span>Oh no</span>
2261 </p>
2262 !! end
2263
2264 !! test
2265 pre-save transform: comment containing gallery (bug 5024)
2266 !! options
2267 pst
2268 !! input
2269 <!-- <gallery>data</gallery> -->
2270 !!result
2271 <!-- <gallery>data</gallery> -->
2272 !!end
2273
2274 !! test
2275 pre-save transform: comment containing extension
2276 !! options
2277 pst
2278 !! input
2279 <!-- <tag>data</tag> -->
2280 !!result
2281 <!-- <tag>data</tag> -->
2282 !!end
2283
2284 !! test
2285 pre-save transform: comment containing nowiki
2286 !! options
2287 pst
2288 !! input
2289 <!-- <nowiki>data</nowiki> -->
2290 !!result
2291 <!-- <nowiki>data</nowiki> -->
2292 !!end
2293
2294 !! test
2295 pre-save transform: comment containing math
2296 !! options
2297 pst
2298 !! input
2299 <!-- <math>data</math> -->
2300 !!result
2301 <!-- <math>data</math> -->
2302 !!end
2303
2304
2305 ###
2306 ### Message transform tests
2307 ###
2308 !! test
2309 message transform: magic variables
2310 !! options
2311 msg
2312 !! input
2313 {{SITENAME}}
2314 !! result
2315 MediaWiki
2316 !! end
2317
2318 !! test
2319 message transform: should not transform wiki markup
2320 !! options
2321 msg
2322 !! input
2323 ''test''
2324 !! result
2325 ''test''
2326 !! end
2327
2328 ###
2329 ### Images
2330 ###
2331 !! test
2332 Simple image
2333 !! input
2334 [[Image:foobar.jpg]]
2335 !! result
2336 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2337 </p>
2338 !! end
2339
2340 !! test
2341 Right-aligned image
2342 !! input
2343 [[Image:foobar.jpg|right]]
2344 !! result
2345 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="http://example.com/images/3/3a/Foobar.jpg" alt="" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
2346
2347 !! end
2348
2349 !! test
2350 Image with caption
2351 !! input
2352 [[Image:foobar.jpg|right|Caption text]]
2353 !! result
2354 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Caption text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
2355
2356 !! end
2357
2358 !! test
2359 Image with frame and link
2360 !! input
2361 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
2362 !! result
2363 <div class="thumb tleft"><div style="width:1943px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a test image Main Page"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This is a test image Main Page" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" >This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
2364
2365 !! end
2366
2367 !! test
2368 Link to image page
2369 !! input
2370 [[:Image:test]]
2371 !! result
2372 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
2373 </p>
2374 !! end
2375
2376 !! test
2377 Frameless image caption with a free URL
2378 !! input
2379 [[Image:foobar.jpg|http://example.com]]
2380 !! result
2381 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="http://example.com" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2382 </p>
2383 !! end
2384
2385 !! test
2386 Thumbnail image caption with a free URL
2387 !! input
2388 [[Image:foobar.jpg|thumb|http://example.com]]
2389 !! result
2390 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="http://example.com" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a></div></div></div>
2391
2392 !! end
2393
2394 !! test
2395 BUG 1887: A ISBN with a thumbnail
2396 !! input
2397 [[Image:foobar.jpg|thumb|ISBN 12354]]
2398 !! result
2399 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="ISBN 12354"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="ISBN 12354" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a> <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div><a href="index.php?title=Special:Booksources&amp;isbn=12354" class="internal">ISBN 12354</a></div></div></div>
2400 !! end
2401
2402 !! test
2403 BUG 1887: A <math> with a thumbnail
2404 !! input
2405 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2406 !! result
2407 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="2+2"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="2+2" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a> <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div>&lt;math&gt;2+2&lt;math&gt;</div></div></div>
2408 !! end
2409
2410 # Pending resolution to bug 368
2411 !! test
2412 BUG 648: Frameless image caption with a link
2413 !! input
2414 [[Image:foobar.jpg|text with a [[link]] in it]]
2415 !! result
2416 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2417 </p>
2418 !! end
2419
2420 !! test
2421 BUG 648: Frameless image caption with a link (suffix)
2422 !! input
2423 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2424 !! result
2425 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a linkfoo in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2426 </p>
2427 !! end
2428
2429 !! test
2430 BUG 648: Frameless image caption with an interwiki link
2431 !! input
2432 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2433 !! result
2434 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a MeatBall:Link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2435 </p>
2436 !! end
2437
2438 !! test
2439 BUG 648: Frameless image caption with a piped interwiki link
2440 !! input
2441 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2442 !! result
2443 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2444 </p>
2445 !! end
2446
2447 !! test
2448 Escape HTML special chars in image alt text
2449 !! input
2450 [[Image:foobar.jpg|& < > "]]
2451 !! result
2452 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&amp; &lt; &gt; &quot;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2453 </p>
2454 !! end
2455
2456 !! test
2457 BUG 499: Alt text should have &#1234;, not &amp;1234;
2458 !! input
2459 [[Image:foobar.jpg|&#9792;]]
2460 !! result
2461 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&#9792;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2462 </p>
2463 !! end
2464
2465 !! test
2466 Broken image caption with link
2467 !! input
2468 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2469 !! result
2470 <p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link.
2471 </p>
2472 !! end
2473
2474 !! test
2475 Image caption containing another image
2476 !! input
2477 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2478 !! result
2479 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a caption with another Image:Icon.png inside it!"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="This is a caption with another Image:Icon.png inside it!" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="Image:Icon.png">Image:Icon.png</a> inside it!</div></div></div>
2480
2481 !! end
2482
2483 !! test
2484 Image caption containing a newline
2485 !! input
2486 [[Image:Foobar.jpg|This
2487 *is some text]]
2488 !! result
2489 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This *is some text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2490 </p>
2491 !!end
2492
2493
2494 !! test
2495 Bug 3090: External links other than http: in image captions
2496 !! input
2497 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2498 !! result
2499 <div class="thumb tright"><div style="width:202px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This caption has irc and Secure ext links in it."><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" alt="This caption has irc and Secure ext links in it." width="200" height="23" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This caption has <a href="irc://example.net" class='external text' title="irc://example.net" rel="nofollow">irc</a> and <a href="https://example.com" class='external text' title="https://example.com" rel="nofollow">Secure</a> ext links in it.</div></div></div>
2500
2501 !! end
2502
2503
2504 ###
2505 ### Subpages
2506 ###
2507 !! article
2508 Subpage test/subpage
2509 !! text
2510 foo
2511 !! endarticle
2512
2513 !! test
2514 Subpage link
2515 !! options
2516 subpage title=[[Subpage test]]
2517 !! input
2518 [[/subpage]]
2519 !! result
2520 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2521 </p>
2522 !! end
2523
2524 !! test
2525 Subpage noslash link
2526 !! options
2527 subpage title=[[Subpage test]]
2528 !!input
2529 [[/subpage/]]
2530 !! result
2531 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2532 </p>
2533 !! end
2534
2535 !! test
2536 Disabled subpages
2537 !! input
2538 [[/subpage]]
2539 !! result
2540 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2541 </p>
2542 !! end
2543
2544 !! test
2545 BUG 561: {{/Subpage}}
2546 !! options
2547 subpage title=[[Page]]
2548 !! input
2549 {{/Subpage}}
2550 !! result
2551 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2552 </p>
2553 !! end
2554
2555 ###
2556 ### Categories
2557 ###
2558 !! article
2559 Category:MediaWiki User's Guide
2560 !! text
2561 blah
2562 !! endarticle
2563
2564 !! test
2565 Link to category
2566 !! input
2567 [[:Category:MediaWiki User's Guide]]
2568 !! result
2569 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2570 </p>
2571 !! end
2572
2573 !! test
2574 Simple category
2575 !! options
2576 cat
2577 !! input
2578 [[Category: MediaWiki User's Guide]]
2579 !! result
2580 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2581 !! end
2582
2583 ###
2584 ### Inter-language links
2585 ###
2586 !! test
2587 Inter-language links
2588 !! options
2589 ill
2590 !! input
2591 [[es:Alimento]]
2592 [[fr:Nourriture]]
2593 [[zh:&#39135;&#21697;]]
2594 !! result
2595 es:Alimento fr:Nourriture zh:食品
2596 !! end
2597
2598 ###
2599 ### Sections
2600 ###
2601 !! test
2602 Basic section headings
2603 !! options
2604 title=[[Parser test script]]
2605 !! input
2606 == Headline 1 ==
2607 Some text
2608
2609 ==Headline 2==
2610 More
2611 ===Smaller headline===
2612 Blah blah
2613 !! result
2614 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
2615 <p>Some text
2616 </p>
2617 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2>Headline 2</h2>
2618 <p>More
2619 </p>
2620 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Smaller_headline"></a><h3>Smaller headline</h3>
2621 <p>Blah blah
2622 </p>
2623 !! end
2624
2625 !! test
2626 Section headings with TOC
2627 !! options
2628 title=[[Parser test script]]
2629 !! input
2630 == Headline 1 ==
2631 === Subheadline 1 ===
2632 ===== Skipping a level =====
2633 ====== Skipping a level ======
2634
2635 == Headline 2 ==
2636 Some text
2637 ===Another headline===
2638 !! result
2639 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2640 <ul>
2641 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2642 <ul>
2643 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2644 <ul>
2645 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2646 <ul>
2647 <li class='toclevel-4'><a href="#Skipping_a_level_2"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Skipping a level</span></a></li>
2648 </ul>
2649 </li>
2650 </ul>
2651 </li>
2652 </ul>
2653 </li>
2654 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2655 <ul>
2656 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2657 </ul>
2658 </li>
2659 </ul>
2660 </td></tr></table>
2661 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2662 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
2663 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Subheadline_1"></a><h3> Subheadline 1 </h3>
2664 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Skipping_a_level"></a><h5> Skipping a level </h5>
2665 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=4" title="Parser test script">edit</a>]</div><a name="Skipping_a_level_2"></a><h6> Skipping a level </h6>
2666 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=5" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2> Headline 2 </h2>
2667 <p>Some text
2668 </p>
2669 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=6" title="Parser test script">edit</a>]</div><a name="Another_headline"></a><h3>Another headline</h3>
2670
2671 !! end
2672
2673 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2674 !! test
2675 Handling of sections up to level 6 and beyond
2676 !! input
2677 = Level 1 Heading=
2678 == Level 2 Heading==
2679 === Level 3 Heading===
2680 ==== Level 4 Heading====
2681 ===== Level 5 Heading=====
2682 ====== Level 6 Heading======
2683 ======= Level 7 Heading=======
2684 ======== Level 8 Heading========
2685 ========= Level 9 Heading=========
2686 ========== Level 10 Heading==========
2687 !! result
2688 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2689 <ul>
2690 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2691 <ul>
2692 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2693 <ul>
2694 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2695 <ul>
2696 <li class='toclevel-4'><a href="#Level_4_Heading"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Level 4 Heading</span></a>
2697 <ul>
2698 <li class='toclevel-5'><a href="#Level_5_Heading"><span class="tocnumber">1.1.1.1.1</span> <span class="toctext">Level 5 Heading</span></a>
2699 <ul>
2700 <li class='toclevel-6'><a href="#Level_6_Heading"><span class="tocnumber">1.1.1.1.1.1</span> <span class="toctext">Level 6 Heading</span></a></li>
2701 <li class='toclevel-6'><a href="#.3D_Level_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">= Level 7 Heading=</span></a></li>
2702 <li class='toclevel-6'><a href="#.3D.3D_Level_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">== Level 8 Heading==</span></a></li>
2703 <li class='toclevel-6'><a href="#.3D.3D.3D_Level_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">=== Level 9 Heading===</span></a></li>
2704 <li class='toclevel-6'><a href="#.3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">==== Level 10 Heading====</span></a></li>
2705 </ul>
2706 </li>
2707 </ul>
2708 </li>
2709 </ul>
2710 </li>
2711 </ul>
2712 </li>
2713 </ul>
2714 </li>
2715 </ul>
2716 </td></tr></table>
2717 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2718 </p>
2719 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Parser test">edit</a>]</div><a name="Level_1_Heading"></a><h1> Level 1 Heading</h1>
2720 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Parser test">edit</a>]</div><a name="Level_2_Heading"></a><h2> Level 2 Heading</h2>
2721 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Parser test">edit</a>]</div><a name="Level_3_Heading"></a><h3> Level 3 Heading</h3>
2722 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Parser test">edit</a>]</div><a name="Level_4_Heading"></a><h4> Level 4 Heading</h4>
2723 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Parser test">edit</a>]</div><a name="Level_5_Heading"></a><h5> Level 5 Heading</h5>
2724 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Parser test">edit</a>]</div><a name="Level_6_Heading"></a><h6> Level 6 Heading</h6>
2725 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Parser test">edit</a>]</div><a name=".3D_Level_7_Heading.3D"></a><h6>= Level 7 Heading=</h6>
2726 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Parser test">edit</a>]</div><a name=".3D.3D_Level_8_Heading.3D.3D"></a><h6>== Level 8 Heading==</h6>
2727 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Parser test">edit</a>]</div><a name=".3D.3D.3D_Level_9_Heading.3D.3D.3D"></a><h6>=== Level 9 Heading===</h6>
2728 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Parser test">edit</a>]</div><a name=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"></a><h6>==== Level 10 Heading====</h6>
2729
2730 !! end
2731
2732 !! test
2733 Resolving duplicate section names
2734 !! options
2735 title=[[Parser test script]]
2736 !! input
2737 == Foo bar ==
2738 == Foo bar ==
2739 !! result
2740 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Foo_bar"></a><h2> Foo bar </h2>
2741 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Foo_bar_2"></a><h2> Foo bar </h2>
2742
2743 !! end
2744
2745 !! article
2746 Template:sections
2747 !! text
2748 ===Section 1===
2749 ==Section 2==
2750 !! endarticle
2751
2752 !! test
2753 Template with sections, __NOTOC__
2754 !! options
2755 title=[[Parser test script]]
2756 !! input
2757 __NOTOC__
2758 ==Section 0==
2759 {{sections}}
2760 ==Section 4==
2761 !! result
2762 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Section_0"></a><h2>Section 0</h2>
2763 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=1" title="Template:Sections">edit</a>]</div><a name="Section_1"></a><h3>Section 1</h3>
2764 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=2" title="Template:Sections">edit</a>]</div><a name="Section_2"></a><h2>Section 2</h2>
2765 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Section_4"></a><h2>Section 4</h2>
2766
2767 !! end
2768
2769 !! test
2770 __NOEDITSECTION__ keyword
2771 !! input
2772 __NOEDITSECTION__
2773 ==Section 1==
2774 ==Section 2==
2775 !! result
2776 <a name="Section_1"></a><h2>Section 1</h2>
2777 <a name="Section_2"></a><h2>Section 2</h2>
2778
2779 !! end
2780
2781 !! test
2782 Link inside a section heading
2783 !! options
2784 title=[[Parser test script]]
2785 !! input
2786 ==Section with a [[Main Page|link]] in it==
2787 !! result
2788 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Section_with_a_link_in_it"></a><h2>Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</h2>
2789
2790 !! end
2791
2792
2793 !! test
2794 BUG 1219 URL next to image (good)
2795 !! input
2796 http://example.com [[Image:foobar.jpg]]
2797 !! result
2798 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a> <a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2799 </p>
2800 !!end
2801
2802 !! test
2803 BUG 1219 URL next to image (broken)
2804 !! input
2805 http://example.com[[Image:foobar.jpg]]
2806 !! result
2807 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2808 </p>
2809 !!end
2810
2811 !! test
2812 Bug 1186 news: in the middle of text
2813 !! input
2814 http://en.wikinews.org/wiki/Wikinews:Workplace
2815 !! result
2816 <p><a href="http://en.wikinews.org/wiki/Wikinews:Workplace" class='external free' title="http://en.wikinews.org/wiki/Wikinews:Workplace" rel="nofollow">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
2817 </p>
2818 !!end
2819
2820
2821 !! test
2822 Namespaced link must have a title
2823 !! input
2824 [[Project:]]
2825 !! result
2826 <p>[[Project:]]
2827 </p>
2828 !!end
2829
2830 !! test
2831 Namespaced link must have a title (bad fragment version)
2832 !! input
2833 [[Project:#fragment]]
2834 !! result
2835 <p>[[Project:#fragment]]
2836 </p>
2837 !!end
2838
2839
2840 !! test
2841 div with no attributes
2842 !! input
2843 <div>HTML rocks</div>
2844 !! result
2845 <div>HTML rocks</div>
2846
2847 !! end
2848
2849 !! test
2850 div with double-quoted attribute
2851 !! input
2852 <div id="rock">HTML rocks</div>
2853 !! result
2854 <div id="rock">HTML rocks</div>
2855
2856 !! end
2857
2858 !! test
2859 div with single-quoted attribute
2860 !! input
2861 <div id='rock'>HTML rocks</div>
2862 !! result
2863 <div id="rock">HTML rocks</div>
2864
2865 !! end
2866
2867 !! test
2868 div with unquoted attribute
2869 !! input
2870 <div id=rock>HTML rocks</div>
2871 !! result
2872 <div id="rock">HTML rocks</div>
2873
2874 !! end
2875
2876 !! test
2877 div with illegal double attributes
2878 !! input
2879 <div align="center" align="right">HTML rocks</div>
2880 !! result
2881 <div align="right">HTML rocks</div>
2882
2883 !!end
2884
2885 !! test
2886 HTML multiple attributes correction
2887 !! input
2888 <p class="error" class="awesome">Awesome!</p>
2889 !! result
2890 <p class="awesome">Awesome!</p>
2891
2892 !!end
2893
2894 !! test
2895 Table multiple attributes correction
2896 !! input
2897 {|
2898 !+ class="error" class="awesome"| status
2899 |}
2900 !! result
2901 <table>
2902 <tr>
2903 <th class="awesome"> status
2904 </th></tr></table>
2905
2906 !!end
2907
2908 !! test
2909 DIV IN UPPERCASE
2910 !! input
2911 <DIV ALIGN="center">HTML ROCKS</DIV>
2912 !! result
2913 <div align="center">HTML ROCKS</div>
2914
2915 !!end
2916
2917
2918 !! test
2919 text with amp in the middle of nowhere
2920 !! input
2921 Remember AT&T?
2922 !!result
2923 <p>Remember AT&amp;T?
2924 </p>
2925 !! end
2926
2927 !! test
2928 text with character entity: eacute
2929 !! input
2930 I always thought &eacute; was a cute letter.
2931 !! result
2932 <p>I always thought &eacute; was a cute letter.
2933 </p>
2934 !! end
2935
2936 !! test
2937 text with undefined character entity: xacute
2938 !! input
2939 I always thought &xacute; was a cute letter.
2940 !! result
2941 <p>I always thought &amp;xacute; was a cute letter.
2942 </p>
2943 !! end
2944
2945
2946 ###
2947 ### Media links
2948 ###
2949
2950 !! test
2951 Media link
2952 !! input
2953 [[Media:Foobar.jpg]]
2954 !! result
2955 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2956 </p>
2957 !! end
2958
2959 !! test
2960 Media link with text
2961 !! input
2962 [[Media:Foobar.jpg|A neat file to look at]]
2963 !! result
2964 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2965 </p>
2966 !! end
2967
2968 # FIXME: this is still bad HTML tag nesting
2969 !! test
2970 Media link with nasty text
2971 !! input
2972 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2973 !! result
2974 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie) onfoo="</div></a>
2975 </p>
2976 !! end
2977
2978 !! test
2979 Media link to nonexistent file (bug 1702)
2980 !! input
2981 [[Media:No such.jpg]]
2982 !! result
2983 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2984 </p>
2985 !! end
2986
2987 !! test
2988 Image link to nonexistent file (bug 1850 - good)
2989 !! input
2990 [[Image:No such.jpg]]
2991 !! result
2992 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
2993 </p>
2994 !! end
2995
2996 !! test
2997 :Image link to nonexistent file (bug 1850 - bad)
2998 !! input
2999 [[:Image:No such.jpg]]
3000 !! result
3001 <p><a href="/index.php?title=Image:No_such.jpg&amp;action=edit" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
3002 </p>
3003 !! end
3004
3005
3006
3007 !! test
3008 Character reference normalization in link text (bug 1938)
3009 !! input
3010 [[Main Page|this&that]]
3011 !! result
3012 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
3013 </p>
3014 !!end
3015
3016 !! test
3017 Empty attribute crash test (bug 2067)
3018 !! input
3019 <font color="">foo</font>
3020 !! result
3021 <p><font color="">foo</font>
3022 </p>
3023 !! end
3024
3025 !! test
3026 Empty attribute crash test single-quotes (bug 2067)
3027 !! input
3028 <font color=''>foo</font>
3029 !! result
3030 <p><font color="">foo</font>
3031 </p>
3032 !! end
3033
3034 !! test
3035 Attribute test: equals, then nothing
3036 !! input
3037 <font color=>foo</font>
3038 !! result
3039 <p><font>foo</font>
3040 </p>
3041 !! end
3042
3043 !! test
3044 Attribute test: unquoted value
3045 !! input
3046 <font color=x>foo</font>
3047 !! result
3048 <p><font color="x">foo</font>
3049 </p>
3050 !! end
3051
3052 !! test
3053 Attribute test: unquoted but illegal value (hash)
3054 !! input
3055 <font color=#x>foo</font>
3056 !! result
3057 <p><font color="#x">foo</font>
3058 </p>
3059 !! end
3060
3061 !! test
3062 Attribute test: no value
3063 !! input
3064 <font color>foo</font>
3065 !! result
3066 <p><font color="color">foo</font>
3067 </p>
3068 !! end
3069
3070 !! test
3071 Bug 2095: link with three closing brackets
3072 !! input
3073 [[Main Page]]]
3074 !! result
3075 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
3076 </p>
3077 !! end
3078
3079 !! test
3080 Bug 2095: link with pipe and three closing brackets
3081 !! input
3082 [[Main Page|link]]]
3083 !! result
3084 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
3085 </p>
3086 !! end
3087
3088
3089 ###
3090 ### Safety
3091 ###
3092
3093 !! article
3094 Template:Dangerous attribute
3095 !! text
3096 " onmouseover="alert(document.cookie)
3097 !! endarticle
3098
3099 !! article
3100 Template:Dangerous style attribute
3101 !! text
3102 border-size: expression(alert(document.cookie))
3103 !! endarticle
3104
3105 !! article
3106 Template:Div style
3107 !! text
3108 <div style="float: right; {{{1}}}">Magic div</div>
3109 !! endarticle
3110
3111 !! test
3112 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
3113 !! input
3114 <div title="{{test}}"></div>
3115 !! result
3116 <div title="This is a test template"></div>
3117
3118 !! end
3119
3120 !! test
3121 Bug 2304: HTML attribute safety (dangerous template; 2309)
3122 !! input
3123 <div title="{{dangerous attribute}}"></div>
3124 !! result
3125 <div title=""></div>
3126
3127 !! end
3128
3129 !! test
3130 Bug 2304: HTML attribute safety (dangerous style template; 2309)
3131 !! input
3132 <div style="{{dangerous style attribute}}"></div>
3133 !! result
3134 <div></div>
3135
3136 !! end
3137
3138 !! test
3139 Bug 2304: HTML attribute safety (safe parameter; 2309)
3140 !! input
3141 {{div style|width: 200px}}
3142 !! result
3143 <div style="float: right; width: 200px">Magic div</div>
3144
3145 !! end
3146
3147 !! test
3148 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
3149 !! input
3150 {{div style|width: expression(alert(document.cookie))}}
3151 !! result
3152 <div>Magic div</div>
3153
3154 !! end
3155
3156 !! test
3157 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
3158 !! input
3159 {{div style|"><script>alert(document.cookie)</script>}}
3160 !! result
3161 <div>Magic div</div>
3162
3163 !! end
3164
3165 !! test
3166 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
3167 !! input
3168 {{div style|" ><script>alert(document.cookie)</script>}}
3169 !! result
3170 <div style="float: right; ">Magic div</div>
3171
3172 !! end
3173
3174 !! test
3175 Bug 2304: HTML attribute safety (link)
3176 !! input
3177 <div title="[[Main Page]]"></div>
3178 !! result
3179 <div title="&#91;&#91;Main Page]]"></div>
3180
3181 !! end
3182
3183 !! test
3184 Bug 2304: HTML attribute safety (italics)
3185 !! input
3186 <div title="''foobar''"></div>
3187 !! result
3188 <div title="&#39;&#39;foobar&#39;&#39;"></div>
3189
3190 !! end
3191
3192 !! test
3193 Bug 2304: HTML attribute safety (bold)
3194 !! input
3195 <div title="'''foobar'''"></div>
3196 !! result
3197 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
3198
3199 !! end
3200
3201
3202 !! test
3203 Bug 2304: HTML attribute safety (ISBN)
3204 !! input
3205 <div title="ISBN 1234567890"></div>
3206 !! result
3207 <div title="&#73;SBN 1234567890"></div>
3208
3209 !! end
3210
3211 !! test
3212 Bug 2304: HTML attribute safety (RFC)
3213 !! input
3214 <div title="RFC 1234"></div>
3215 !! result
3216 <div title="&#82;FC 1234"></div>
3217
3218 !! end
3219
3220 !! test
3221 Bug 2304: HTML attribute safety (PMID)
3222 !! input
3223 <div title="PMID 1234567890"></div>
3224 !! result
3225 <div title="&#80;MID 1234567890"></div>
3226
3227 !! end
3228
3229 !! test
3230 Bug 2304: HTML attribute safety (web link)
3231 !! input
3232 <div title="http://example.com/"></div>
3233 !! result
3234 <div title="http&#58;//example.com/"></div>
3235
3236 !! end
3237
3238 !! test
3239 Bug 2304: HTML attribute safety (named web link)
3240 !! input
3241 <div title="[http://example.com/ link]"></div>
3242 !! result
3243 <div title="&#91;http&#58;//example.com/ link]"></div>
3244
3245 !! end
3246
3247 !! test
3248 Bug 3244: HTML attribute safety (extension; safe)
3249 !! input
3250 <div style="<nowiki>background:blue</nowiki>"></div>
3251 !! result
3252 <div style="background:blue"></div>
3253
3254 !! end
3255
3256 !! test
3257 Bug 3244: HTML attribute safety (extension; unsafe)
3258 !! input
3259 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
3260 !! result
3261 <div></div>
3262
3263 !! end
3264
3265 !! test
3266 Math section safety when disabled
3267 !! input
3268 <math><script>alert(document.cookies);</script></math>
3269 !! result
3270 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
3271 </p>
3272 !! end
3273
3274 # More MSIE fun discovered by Tom Gilder
3275
3276 !! test
3277 MSIE CSS safety test: spurious slash
3278 !! input
3279 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
3280 !! result
3281 <div>evil</div>
3282
3283 !! end
3284
3285 !! test
3286 MSIE CSS safety test: hex code
3287 !! input
3288 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3289 !! result
3290 <div>evil</div>
3291
3292 !! end
3293
3294 !! test
3295 MSIE CSS safety test: comment in url
3296 !! input
3297 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3298 !! result
3299 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3300
3301 !! end
3302
3303 !! test
3304 MSIE CSS safety test: comment in expression
3305 !! input
3306 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3307 !! result
3308 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3309
3310 !! end
3311
3312
3313 !! test
3314 Table attribute legitimate extension
3315 !! input
3316 {|
3317 !+ style="<nowiki>color:blue</nowiki>"| status
3318 |}
3319 !! result
3320 <table>
3321 <tr>
3322 <th style="color:blue"> status
3323 </th></tr></table>
3324
3325 !!end
3326
3327 !! test
3328 Table attribute safety
3329 !! input
3330 {|
3331 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
3332 |}
3333 !! result
3334 <table>
3335 <tr>
3336 <th> status
3337 </th></tr></table>
3338
3339 !! end
3340
3341 ###
3342 ### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
3343 ###
3344 !! test
3345 Parser hook: empty input
3346 !! input
3347 <tag></tag>
3348 !! result
3349 <pre>
3350 string(0) ""
3351 array(0) {
3352 }
3353 </pre>
3354
3355 !! end
3356
3357 !! test
3358 Parser hook: empty input using terminated empty elements
3359 !! input
3360 <tag/>
3361 !! result
3362 <pre>
3363 NULL
3364 array(0) {
3365 }
3366 </pre>
3367
3368 !! end
3369
3370 !! test
3371 Parser hook: basic input
3372 !! input
3373 <tag>input</tag>
3374 !! result
3375 <pre>
3376 string(5) "input"
3377 array(0) {
3378 }
3379 </pre>
3380
3381 !! end
3382
3383
3384 !! test
3385 Parser hook: case insensetive
3386 !! input
3387 <TAG>input</TAG>
3388 !! result
3389 <pre>
3390 string(5) "input"
3391 array(0) {
3392 }
3393 </pre>
3394
3395 !! end
3396
3397
3398 !! test
3399 Parser hook: case insensetive, redux
3400 !! input
3401 <TaG>input</TAg>
3402 !! result
3403 <pre>
3404 string(5) "input"
3405 array(0) {
3406 }
3407 </pre>
3408
3409 !! end
3410
3411 !! test
3412 Parser hook: nested tags
3413 !! options
3414 noxml
3415 !! input
3416 <tag><tag></tag></tag>
3417 !! result
3418 <pre>
3419 string(5) "<tag>"
3420 array(0) {
3421 }
3422 </pre>&lt;/tag&gt;
3423
3424 !! end
3425
3426 !! test
3427 Parser hook: basic arguments
3428 !! input
3429 <tag width=200 height = "100" depth = '50' square></tag>
3430 !! result
3431 <pre>
3432 string(0) ""
3433 array(4) {
3434 ["width"]=>
3435 string(3) "200"
3436 ["height"]=>
3437 string(3) "100"
3438 ["depth"]=>
3439 string(2) "50"
3440 ["square"]=>
3441 string(6) "square"
3442 }
3443 </pre>
3444
3445 !! end
3446
3447 !! test
3448 Parser hook: empty input using terminated empty elements (bug 2374)
3449 !! input
3450 <tag foo=bar/>text
3451 !! result
3452 <pre>
3453 NULL
3454 array(1) {
3455 ["foo"]=>
3456 string(3) "bar"
3457 }
3458 </pre>text
3459
3460 !! end
3461
3462 # </tag> should be output literally since there is no matching tag that begins it
3463 !! test
3464 Parser hook: basic arguments using terminated empty elements (bug 2374)
3465 !! input
3466 <tag width=200 height = "100" depth = '50' square/>
3467 other stuff
3468 </tag>
3469 !! result
3470 <pre>
3471 NULL
3472 array(4) {
3473 ["width"]=>
3474 string(3) "200"
3475 ["height"]=>
3476 string(3) "100"
3477 ["depth"]=>
3478 string(2) "50"
3479 ["square"]=>
3480 string(6) "square"
3481 }
3482 </pre>
3483 <p>other stuff
3484 &lt;/tag&gt;
3485 </p>
3486 !! end
3487
3488 ###
3489 ### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
3490 ###
3491
3492 !! test
3493 Parser hook: static parser hook not inside a comment
3494 !! input
3495 <statictag>hello, world</statictag>
3496 <statictag action=flush/>
3497 !! result
3498 <p>hello, world
3499 </p>
3500 !! end
3501
3502
3503 !! test
3504 Parser hook: static parser hook inside a comment
3505 !! input
3506 <!-- <statictag>hello, world</statictag> -->
3507 <statictag action=flush/>
3508 !! result
3509 <p><br />
3510 </p>
3511 !! end
3512
3513 # Nested template calls; this case was broken by Parser.php rev 1.506,
3514 # since reverted.
3515
3516 !! article
3517 Template:One-parameter
3518 !! text
3519 (My parameter is: {{{1}}})
3520 !! endarticle
3521
3522 !! article
3523 Template:Map-one-parameter
3524 !! text
3525 {{{{{1}}}|{{{2}}}}}
3526 !! endarticle
3527
3528 !! test
3529 Nested template calls
3530 !! input
3531 {{Map-one-parameter|One-parameter|param}}
3532 !! result
3533 <p>(My parameter is: param)
3534 </p>
3535 !! end
3536
3537
3538 ###
3539 ### Sanitizer
3540 ###
3541 !! test
3542 Sanitizer: Closing of open tags
3543 !! input
3544 <s></s><table></table>
3545 !! result
3546 <s></s><table></table>
3547
3548 !! end
3549
3550 !! test
3551 Sanitizer: Closing of open but not closed tags
3552 !! input
3553 <s>foo
3554 !! result
3555 <p><s>foo</s>
3556 </p>
3557 !! end
3558
3559 !! test
3560 Sanitizer: Closing of closed but not open tags
3561 !! input
3562 </s>
3563 !! result
3564 <p>&lt;/s&gt;
3565 </p>
3566 !! end
3567
3568 !! test
3569 Sanitizer: Closing of closed but not open table tags
3570 !! input
3571 Table not started</td></tr></table>
3572 !! result
3573 <p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
3574 </p>
3575 !! end
3576
3577 !! test
3578 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
3579 !! input
3580 <span id="æ: v">byte</span>[[#æ: v|backlink]]
3581 !! result
3582 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
3583 </p>
3584 !! end
3585
3586 !! test
3587 Sanitizer: Validating the contents of the id attribute (bug 4515)
3588 !! input
3589 <br id=9 />
3590 !! result
3591 Something, but defenetly not <br id="9" />...
3592 !! end
3593
3594 TODO:
3595 more images
3596 more tables
3597 math
3598 character entities
3599 and much more