Save the last modified timestamp to the parser cache, to avoid the need for a revisio...
[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 ### Quotes
711 ###
712
713 !! test
714 Quotes
715 !! input
716 Normal text. '''Bold text.''' Normal text. ''Italic text.''
717
718 Normal text. '''''Bold italic text.''''' Normal text.
719 !!result
720 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
721 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
722 </p>
723 !! end
724
725
726 !! test
727 Unclosed and unmatched quotes
728 !! input
729 '''''Bold italic text '''with bold deactivated''' in between.'''''
730
731 '''''Bold italic text ''with italic deactivated'' in between.'''''
732
733 '''Bold text..
734
735 ..spanning two paragraphs (should not work).'''
736
737 '''Bold tag left open
738
739 ''Italic tag left open
740
741 Normal text.
742
743 <!-- Unmatching number of opening, closing tags: -->
744 '''This year''''s election ''should'' beat '''last year''''s.
745
746 ''Tom'''s car is bigger than ''Susan'''s.
747 !! result
748 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
749 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
750 </p><p><b>Bold text..</b>
751 </p><p>..spanning two paragraphs (should not work).<b></b>
752 </p><p><b>Bold tag left open</b>
753 </p><p><i>Italic tag left open</i>
754 </p><p>Normal text.
755 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
756 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
757 </p>
758 !! end
759
760 ###
761 ### Tables
762 ###
763 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
764 ###
765
766 # This should not produce <table></table> as <table><tr><td></td></tr></table>
767 # is the bare minimun required by the spec, see:
768 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
769 !! test
770 A table with no data.
771 !! input
772 {||}
773 !! result
774 !! end
775
776 # A table with nothing but a caption is invalid XHTML, we might want to render
777 # this as <p>caption</p>
778 !! test
779 A table with nothing but a caption
780 !! input
781 {|
782 |+ caption
783 |}
784 !! result
785 <table>
786 <caption> caption
787 </caption>
788 <tr>
789 <td>
790 </td></tr></table>
791 !! end
792
793 !! test
794 Simple table
795 !! input
796 {|
797 | 1 || 2
798 |-
799 | 3 || 4
800 |}
801 !! result
802 <table>
803 <tr>
804 <td> 1 </td><td> 2
805 </td></tr>
806 <tr>
807 <td> 3 </td><td> 4
808 </td></tr></table>
809
810 !! end
811
812 !! test
813 Multiplication table
814 !! input
815 {| border="1" cellpadding="2"
816 |+Multiplication table
817 |-
818 ! &times; !! 1 !! 2 !! 3
819 |-
820 ! 1
821 | 1 || 2 || 3
822 |-
823 ! 2
824 | 2 || 4 || 6
825 |-
826 ! 3
827 | 3 || 6 || 9
828 |-
829 ! 4
830 | 4 || 8 || 12
831 |-
832 ! 5
833 | 5 || 10 || 15
834 |}
835 !! result
836 <table border="1" cellpadding="2">
837 <caption>Multiplication table
838 </caption>
839 <tr>
840 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
841 </th></tr>
842 <tr>
843 <th> 1
844 </th><td> 1 </td><td> 2 </td><td> 3
845 </td></tr>
846 <tr>
847 <th> 2
848 </th><td> 2 </td><td> 4 </td><td> 6
849 </td></tr>
850 <tr>
851 <th> 3
852 </th><td> 3 </td><td> 6 </td><td> 9
853 </td></tr>
854 <tr>
855 <th> 4
856 </th><td> 4 </td><td> 8 </td><td> 12
857 </td></tr>
858 <tr>
859 <th> 5
860 </th><td> 5 </td><td> 10 </td><td> 15
861 </td></tr></table>
862
863 !! end
864
865 !! test
866 Table rowspan
867 !! input
868 {| align=right border=1
869 | Cell 1, row 1
870 |rowspan=2| Cell 2, row 1 (and 2)
871 | Cell 3, row 1
872 |-
873 | Cell 1, row 2
874 | Cell 3, row 2
875 |}
876 !! result
877 <table align="right" border="1">
878 <tr>
879 <td> Cell 1, row 1
880 </td><td rowspan="2"> Cell 2, row 1 (and 2)
881 </td><td> Cell 3, row 1
882 </td></tr>
883 <tr>
884 <td> Cell 1, row 2
885 </td><td> Cell 3, row 2
886 </td></tr></table>
887
888 !! end
889
890 !! test
891 Nested table
892 !! input
893 {| border=1
894 | &alpha;
895 |
896 {| bgcolor=#ABCDEF border=2
897 |nested
898 |-
899 |table
900 |}
901 |the original table again
902 |}
903 !! result
904 <table border="1">
905 <tr>
906 <td> &alpha;
907 </td><td>
908 <table bgcolor="#ABCDEF" border="2">
909 <tr>
910 <td>nested
911 </td></tr>
912 <tr>
913 <td>table
914 </td></tr></table>
915 </td><td>the original table again
916 </td></tr></table>
917
918 !! end
919
920 !! test
921 Invalid attributes in table cell (bug 1830)
922 !! input
923 {|
924 |Cell:|broken
925 |}
926 !! result
927 <table>
928 <tr>
929 <td>broken
930 </td></tr></table>
931
932 !! end
933
934
935 ###
936 ### Internal links
937 ###
938 !! test
939 Plain link, capitalized
940 !! input
941 [[Main Page]]
942 !! result
943 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
944 </p>
945 !! end
946
947 !! test
948 Plain link, uncapitalized
949 !! input
950 [[main Page]]
951 !! result
952 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
953 </p>
954 !! end
955
956 !! test
957 Piped link
958 !! input
959 [[Main Page|The Main Page]]
960 !! result
961 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
962 </p>
963 !! end
964
965 !! test
966 Broken link
967 !! input
968 [[Zigzagzogzagzig]]
969 !! result
970 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
971 </p>
972 !! end
973
974 !! test
975 Link with prefix
976 !! input
977 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
978 !! result
979 <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>
980 </p>
981 !! end
982
983 !! test
984 Link with suffix
985 !! input
986 [[Main Page]]xxx, [[Main Page]]XXX
987 !! result
988 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
989 </p>
990 !! end
991
992 !! test
993 Link with 3 brackets
994 !! input
995 [[[main page]]]
996 !! result
997 <p>[[[main page]]]
998 </p>
999 !! end
1000
1001 !! test
1002 Piped link with 3 brackets
1003 !! input
1004 [[[main page|the main page]]]
1005 !! result
1006 <p>[[[main page|the main page]]]
1007 </p>
1008 !! end
1009
1010 !! test
1011 Link with multiple pipes
1012 !! input
1013 [[Main Page|The|Main|Page]]
1014 !! result
1015 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
1016 </p>
1017 !! end
1018
1019 !! test
1020 Link to namespaces
1021 !! input
1022 [[Talk:Parser testing]], [[Meta:Disclaimers]]
1023 !! result
1024 <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>
1025 </p>
1026 !! end
1027
1028 !! test
1029 Piped link to namespace
1030 !! input
1031 [[Meta:Disclaimers|The disclaimers]]
1032 !! result
1033 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
1034 </p>
1035 !! end
1036
1037 !! test
1038 Link containing }
1039 !! input
1040 [[Usually caused by a typo (oops}]]
1041 !! result
1042 <p>[[Usually caused by a typo (oops}]]
1043 </p>
1044 !! end
1045
1046 !! test
1047 Link containing % (not as a hex sequence)
1048 !! input
1049 [[7% Solution]]
1050 !! result
1051 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1052 </p>
1053 !! end
1054
1055 !! test
1056 Link containing % as a single hex sequence interpreted to char
1057 !! input
1058 [[7%25 Solution]]
1059 !! result
1060 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1061 </p>
1062 !!end
1063
1064 !! test
1065 Link containing % as a double hex sequence interpreted to hex sequence
1066 !! input
1067 [[7%2525 Solution]]
1068 !! result
1069 <p>[[7%2525 Solution]]
1070 </p>
1071 !!end
1072
1073 !! test
1074 Link containing "#<" and "#>" % as a hex sequences
1075 !! input
1076 [[%23%3c]]<!-- Render this as "[[#%3c]]" maybe.. ? -->[[%23%3e]]<!-- ..."[[#%3e]]" ? -->
1077 !! result
1078 <p>[[%23%3c]][[%23%3e]]
1079 </p>
1080 !! end
1081
1082 !! test
1083 Link containing "<#" and ">#" as a hex sequences
1084 !! input
1085 [[%3c%23]][[%3e%23]]
1086 !! result
1087 <p>[[%3c%23]][[%3e%23]]
1088 </p>
1089 !! end
1090
1091 !! test
1092 Plain link to URL
1093 !! input
1094 [[http://www.example.org]]
1095 !! result
1096 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1097 </p>
1098 !! end
1099
1100 # I'm fairly sure the expected result here is wrong.
1101 # We want these to be URL links, not pseudo-pages with URLs for titles....
1102 # However the current output is also pretty screwy.
1103 #
1104 # ----
1105 # I'm changing it to match the current output--it arguably makes more
1106 # sense in the light of the test above. Old expected result was:
1107 #<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>
1108 #</p>
1109 # But I think this test is bordering on "garbage in, garbage out" anyway.
1110 # -- wtm
1111 !! test
1112 Piped link to URL
1113 !! input
1114 Piped link to URL: [[http://www.example.org|an example URL]]
1115 !! result
1116 <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>]
1117 </p>
1118 !! end
1119
1120 !! test
1121 BUG 2: [[page|http://url/]] should link to page, not http://url/
1122 !! input
1123 [[Main Page|http://url/]]
1124 !! result
1125 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1126 </p>
1127 !! end
1128
1129 !! test
1130 BUG 337: Escaped self-links should be bold
1131 !! options
1132 title=[[Bug462]]
1133 !! input
1134 [[Bu&#103;462]] [[Bug462]]
1135 !! result
1136 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1137 </p>
1138 !! end
1139
1140 !! test
1141 Self-link to section should not be bold
1142 !! options
1143 title=[[Main Page]]
1144 !! input
1145 [[Main Page#section]]
1146 !! result
1147 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1148 </p>
1149 !! end
1150
1151 !! test
1152 <nowiki> inside a link
1153 !! input
1154 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1155 !! result
1156 <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>
1157 </p>
1158 !! end
1159
1160 ###
1161 ### Interwiki links (see maintenance/interwiki.sql)
1162 ###
1163
1164 !! test
1165 Inline interwiki link
1166 !! input
1167 [[MeatBall:SoftSecurity]]
1168 !! result
1169 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
1170 </p>
1171 !! end
1172
1173 !! test
1174 Inline interwiki link with empty title (bug 2372)
1175 !! input
1176 [[MeatBall:]]
1177 !! result
1178 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="meatball:">MeatBall:</a>
1179 </p>
1180 !! end
1181
1182 !! test
1183 Interwiki link encoding conversion (bug 1636)
1184 !! input
1185 *[[Wikipedia:ro:Olteni&#0355;a]]
1186 *[[Wikipedia:ro:Olteni&#355;a]]
1187 !! result
1188 <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>
1189 </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>
1190 </li></ul>
1191
1192 !! end
1193
1194 !! test
1195 Interwiki link with fragment (bug 2130)
1196 !! input
1197 [[MeatBall:SoftSecurity#foo]]
1198 !! result
1199 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1200 </p>
1201 !! end
1202
1203 ##
1204 ## XHTML tidiness
1205 ###
1206
1207 !! test
1208 <br> to <br />
1209 !! input
1210 1<br>2<br />3
1211 !! result
1212 <p>1<br />2<br />3
1213 </p>
1214 !! end
1215
1216 !! test
1217 Incorrecly removing closing slashes from correctly formed XHTML
1218 !! input
1219 <br style="clear:both;" />
1220 !! result
1221 <p><br style="clear:both;" />
1222 </p>
1223 !! end
1224
1225 !! test
1226 Failing to transform badly formed HTML into correct XHTML
1227 !! input
1228 <br clear=left>
1229 <br clear=right>
1230 <br clear=all>
1231 !! result
1232 <p><br clear="left" />
1233 <br clear="right" />
1234 <br clear="all" />
1235 </p>
1236 !!end
1237
1238 !! test
1239 Horizontal ruler (should it add that extra space?)
1240 !! input
1241 <hr>
1242 <hr >
1243 foo <hr
1244 > bar
1245 !! result
1246 <hr />
1247 <hr />
1248 foo <hr /> bar
1249
1250 !! end
1251
1252 ###
1253 ### Block-level elements
1254 ###
1255 !! test
1256 Common list
1257 !! input
1258 *Common list
1259 * item 2
1260 *item 3
1261 !! result
1262 <ul><li>Common list
1263 </li><li> item 2
1264 </li><li>item 3
1265 </li></ul>
1266
1267 !! end
1268
1269 !! test
1270 Numbered list
1271 !! input
1272 #Numbered list
1273 #item 2
1274 # item 3
1275 !! result
1276 <ol><li>Numbered list
1277 </li><li>item 2
1278 </li><li> item 3
1279 </li></ol>
1280
1281 !! end
1282
1283 !! test
1284 Mixed list
1285 !! input
1286 *Mixed list
1287 *# with numbers
1288 ** and bullets
1289 *# and numbers
1290 *bullets again
1291 **bullet level 2
1292 ***bullet level 3
1293 ***#Number on level 4
1294 **bullet level 2
1295 **#Number on level 3
1296 **#Number on level 3
1297 *#number level 2
1298 *Level 1
1299 !! result
1300 <ul><li>Mixed list
1301 <ol><li> with numbers
1302 </li></ol>
1303 <ul><li> and bullets
1304 </li></ul>
1305 <ol><li> and numbers
1306 </li></ol>
1307 </li><li>bullets again
1308 <ul><li>bullet level 2
1309 <ul><li>bullet level 3
1310 <ol><li>Number on level 4
1311 </li></ol>
1312 </li></ul>
1313 </li><li>bullet level 2
1314 <ol><li>Number on level 3
1315 </li><li>Number on level 3
1316 </li></ol>
1317 </li></ul>
1318 <ol><li>number level 2
1319 </li></ol>
1320 </li><li>Level 1
1321 </li></ul>
1322
1323 !! end
1324
1325 !! test
1326 List items are not parsed correctly following a <pre> block (bug 785)
1327 !! input
1328 * <pre>foo</pre>
1329 * <pre>bar</pre>
1330 * zar
1331 !! result
1332 <ul><li> <pre>foo</pre>
1333 </li><li> <pre>bar</pre>
1334 </li><li> zar
1335 </li></ul>
1336
1337 !! end
1338
1339 ###
1340 ### Magic Words
1341 ###
1342
1343 !! test
1344 Magic Word: {{CURRENTDAY}}
1345 !! input
1346 {{CURRENTDAY}}
1347 !! result
1348 <p>1
1349 </p>
1350 !! end
1351
1352 !! test
1353 Magic Word: {{CURRENTDAY2}}
1354 !! input
1355 {{CURRENTDAY2}}
1356 !! result
1357 <p>01
1358 </p>
1359 !! end
1360
1361 !! test
1362 Magic Word: {{CURRENTDAYNAME}}
1363 !! input
1364 {{CURRENTDAYNAME}}
1365 !! result
1366 <p>Thursday
1367 </p>
1368 !! end
1369
1370 !! test
1371 Magic Word: {{CURRENTDOW}}
1372 !! input
1373 {{CURRENTDOW}}
1374 !! result
1375 <p>4
1376 </p>
1377 !! end
1378
1379 !! test
1380 Magic Word: {{CURRENTMONTH}}
1381 !! input
1382 {{CURRENTMONTH}}
1383 !! result
1384 <p>01
1385 </p>
1386 !! end
1387
1388 !! test
1389 Magic Word: {{CURRENTMONTHABBREV}}
1390 !! input
1391 {{CURRENTMONTHABBREV}}
1392 !! result
1393 <p>Jan
1394 </p>
1395 !! end
1396
1397 !! test
1398 Magic Word: {{CURRENTMONTHNAME}}
1399 !! input
1400 {{CURRENTMONTHNAME}}
1401 !! result
1402 <p>January
1403 </p>
1404 !! end
1405
1406 !! test
1407 Magic Word: {{CURRENTMONTHNAMEGEN}}
1408 !! input
1409 {{CURRENTMONTHNAMEGEN}}
1410 !! result
1411 <p>January
1412 </p>
1413 !! end
1414
1415 !! test
1416 Magic Word: {{CURRENTTIME}}
1417 !! input
1418 {{CURRENTTIME}}
1419 !! result
1420 <p>00:02
1421 </p>
1422 !! end
1423
1424 !! test
1425 Magic Word: {{CURRENTWEEK}} (@bug 4594)
1426 !! input
1427 {{CURRENTWEEK}}
1428 !! result
1429 <p>1
1430 </p>
1431 !! end
1432
1433 !! test
1434 Magic Word: {{CURRENTYEAR}}
1435 !! input
1436 {{CURRENTYEAR}}
1437 !! result
1438 <p>1970
1439 </p>
1440 !! end
1441
1442 !! test
1443 Magic Word: {{FULLPAGENAME}}
1444 !! options
1445 title=[[User:Ævar Arnfjörð Bjarmason]]
1446 !! input
1447 {{FULLPAGENAME}}
1448 !! result
1449 <p>User:Ævar Arnfjörð Bjarmason
1450 </p>
1451 !! end
1452
1453 !! test
1454 Magic Word: {{FULLPAGENAMEE}}
1455 !! options
1456 title=[[User:Ævar Arnfjörð Bjarmason]]
1457 !! input
1458 {{FULLPAGENAMEE}}
1459 !! result
1460 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1461 </p>
1462 !! end
1463
1464 !! test
1465 Magic Word: {{NAMESPACE}}
1466 !! options
1467 title=[[User:Ævar Arnfjörð Bjarmason]]
1468 disabled # FIXME
1469 !! input
1470 {{NAMESPACE}}
1471 !! result
1472 <p>User
1473 </p>
1474 !! end
1475
1476 !! test
1477 Magic Word: {{NAMESPACEE}}
1478 !! options
1479 title=[[User:Ævar Arnfjörð Bjarmason]]
1480 disabled # FIXME
1481 !! input
1482 {{NAMESPACEE}}
1483 !! result
1484 <p>User
1485 </p>
1486 !! end
1487
1488 !! test
1489 Magic Word: {{NUMBEROFARTICLES}}
1490 !! input
1491 {{NUMBEROFARTICLES}}
1492 !! result
1493 <p>-1
1494 </p>
1495 !! end
1496
1497 !! test
1498 Magic Word: {{NUMBEROFFILES}}
1499 !! input
1500 {{NUMBEROFFILES}}
1501 !! result
1502 <p>1
1503 </p>
1504 !! end
1505
1506 !! test
1507 Magic Word: {{PAGENAME}}
1508 !! options
1509 title=[[User:Ævar Arnfjörð Bjarmason]]
1510 disabled # FIXME
1511 !! input
1512 {{PAGENAME}}
1513 !! result
1514 <p>Ævar Arnfjörð Bjarmason
1515 </p>
1516 !! end
1517
1518 !! test
1519 Magic Word: {{PAGENAMEE}}
1520 !! options
1521 title=[[User:Ævar Arnfjörð Bjarmason]]
1522 !! input
1523 {{PAGENAMEE}}
1524 !! result
1525 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1526 </p>
1527 !! end
1528
1529 !! test
1530 Magic Word: {{REVISIONID}}
1531 !! input
1532 {{REVISIONID}}
1533 !! result
1534 <p>1337
1535 </p>
1536 !! end
1537
1538 !! test
1539 Magic Word: {{SCRIPTPATH}}
1540 !! input
1541 {{SCRIPTPATH}}
1542 !! result
1543 <p>/
1544 </p>
1545 !! end
1546
1547 !! test
1548 Magic Word: {{SERVER}}
1549 !! input
1550 {{SERVER}}
1551 !! result
1552 <p><a href="http://localhost" class='external free' title="http://localhost" rel="nofollow">http://localhost</a>
1553 </p>
1554 !! end
1555
1556 !! test
1557 Magic Word: {{SERVERNAME}}
1558 !! input
1559 {{SERVERNAME}}
1560 !! result
1561 <p>Britney Spears
1562 </p>
1563 !! end
1564
1565 !! test
1566 Magic Word: {{SITENAME}}
1567 !! input
1568 {{SITENAME}}
1569 !! result
1570 <p>MediaWiki
1571 </p>
1572 !! end
1573
1574 !! test
1575 Namespace 1 {{ns:1}}
1576 !! input
1577 {{ns:1}}
1578 !! result
1579 <p>Talk
1580 </p>
1581 !! end
1582
1583 !! test
1584 Namespace 1 {{ns:01}}
1585 !! input
1586 {{ns:01}}
1587 !! result
1588 <p>Talk
1589 </p>
1590 !! end
1591
1592 !! test
1593 Namespace 0 {{ns:0}} (bug 4783)
1594 !! input
1595 {{ns:0}}
1596 !! result
1597
1598 !! end
1599
1600 !! test
1601 Namespace 0 {{ns:00}} (bug 4783)
1602 !! input
1603 {{ns:00}}
1604 !! result
1605
1606 !! end
1607
1608 !! test
1609 Namespace -1 {{ns:-1}}
1610 !! input
1611 {{ns:-1}}
1612 !! result
1613 <p>Special
1614 </p>
1615 !! end
1616
1617 !! test
1618 Namespace Project {{ns:User}}
1619 !! input
1620 {{ns:User}}
1621 !! result
1622 <p>User
1623 </p>
1624 !! end
1625
1626
1627 ###
1628 ### Magic links
1629 ###
1630 !! test
1631 Magic links: internal link to RFC (bug 479)
1632 !! input
1633 [[RFC 123]]
1634 !! result
1635 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1636 </p>
1637 !! end
1638
1639 !! test
1640 Magic links: RFC (bug 479)
1641 !! input
1642 RFC 822
1643 !! result
1644 <p><a href='http://www.ietf.org/rfc/rfc822.txt' class='external' title="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>
1645 </p>
1646 !! end
1647
1648 !! test
1649 Magic links: ISBN (bug 1937)
1650 !! input
1651 ISBN 0-306-40615-2
1652 !! result
1653 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1654 </p>
1655 !! end
1656
1657 !! test
1658 Magic links: PMID incorrectly converts space to underscore
1659 !! input
1660 PMID 1234
1661 !! result
1662 <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>
1663 </p>
1664 !! end
1665
1666 ###
1667 ### Templates
1668 ####
1669
1670 !! test
1671 Nonexistant template
1672 !! input
1673 {{thistemplatedoesnotexist}}
1674 !! result
1675 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1676 </p>
1677 !! end
1678
1679 !! article
1680 Template:test
1681 !! text
1682 This is a test template
1683 !! endarticle
1684
1685 !! test
1686 Simple template
1687 !! input
1688 {{test}}
1689 !! result
1690 <p>This is a test template
1691 </p>
1692 !! end
1693
1694 !! test
1695 Template with explicit namespace
1696 !! input
1697 {{Template:test}}
1698 !! result
1699 <p>This is a test template
1700 </p>
1701 !! end
1702
1703
1704 !! article
1705 Template:paramtest
1706 !! text
1707 This is a test template with parameter {{{param}}}
1708 !! endarticle
1709
1710 !! test
1711 Template parameter
1712 !! input
1713 {{paramtest|param=foo}}
1714 !! result
1715 <p>This is a test template with parameter foo
1716 </p>
1717 !! end
1718
1719 !! article
1720 Template:paramtestnum
1721 !! text
1722 [[{{{1}}}|{{{2}}}]]
1723 !! endarticle
1724
1725 !! test
1726 Template unnamed parameter
1727 !! input
1728 {{paramtestnum|Main Page|the main page}}
1729 !! result
1730 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1731 </p>
1732 !! end
1733
1734 !! article
1735 Template:templatesimple
1736 !! text
1737 (test)
1738 !! endarticle
1739
1740 !! article
1741 Template:templateredirect
1742 !! text
1743 #redirect [[Template:templatesimple]]
1744 !! endarticle
1745
1746 !! article
1747 Template:templateasargtestnum
1748 !! text
1749 {{{{{1}}}}}
1750 !! endarticle
1751
1752 !! article
1753 Template:templateasargtest
1754 !! text
1755 {{template{{{templ}}}}}
1756 !! endarticle
1757
1758 !! article
1759 Template:templateasargtest2
1760 !! text
1761 {{{{{templ}}}}}
1762 !! endarticle
1763
1764 !! test
1765 Template with template name as unnamed argument
1766 !! input
1767 {{templateasargtestnum|templatesimple}}
1768 !! result
1769 <p>(test)
1770 </p>
1771 !! end
1772
1773 !! test
1774 Template with template name as argument
1775 !! input
1776 {{templateasargtest|templ=simple}}
1777 !! result
1778 <p>(test)
1779 </p>
1780 !! end
1781
1782 !! test
1783 Template with template name as argument (2)
1784 !! input
1785 {{templateasargtest2|templ=templatesimple}}
1786 !! result
1787 <p>(test)
1788 </p>
1789 !! end
1790
1791 !! article
1792 Template:templateasargtestdefault
1793 !! text
1794 {{{{{templ|templatesimple}}}}}
1795 !! endarticle
1796
1797 !! article
1798 Template:templa
1799 !! text
1800 '''templ'''
1801 !! endarticle
1802
1803 !! test
1804 Template with default value
1805 !! input
1806 {{templateasargtestdefault}}
1807 !! result
1808 <p>(test)
1809 </p>
1810 !! end
1811
1812 !! test
1813 Template with default value (value set)
1814 !! input
1815 {{templateasargtestdefault|templ=templa}}
1816 !! result
1817 <p><b>templ</b>
1818 </p>
1819 !! end
1820
1821 !! test
1822 Template redirect
1823 !! input
1824 {{templateredirect}}
1825 !! result
1826 <p>(test)
1827 </p>
1828 !! end
1829
1830 !! test
1831 Template with argument in separate line
1832 !! input
1833 {{ templateasargtest |
1834 templ = simple }}
1835 !! result
1836 <p>(test)
1837 </p>
1838 !! end
1839
1840 !! test
1841 Template with complex template as argument
1842 !! input
1843 {{paramtest|
1844 param ={{ templateasargtest |
1845 templ = simple }}}}
1846 !! result
1847 <p>This is a test template with parameter (test)
1848 </p>
1849 !! end
1850
1851 !! test
1852 Template with thumb image (wiht link in description)
1853 !! input
1854 {{paramtest|
1855 param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
1856 !! result
1857 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>
1858
1859 !! end
1860
1861 !! article
1862 Template:complextemplate
1863 !! text
1864 {{{1}}} {{paramtest|
1865 param ={{{param}}}}}
1866 !! endarticle
1867
1868 !! test
1869 Template with complex arguments
1870 !! input
1871 {{complextemplate|
1872 param ={{ templateasargtest |
1873 templ = simple }}|[[Template:complextemplate|link]]}}
1874 !! result
1875 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
1876 </p>
1877 !! end
1878
1879 !! test
1880 BUG 553: link with two variables in a piped link
1881 !! input
1882 {|
1883 |[[{{{1}}}|{{{2}}}]]
1884 |}
1885 !! result
1886 <table>
1887 <tr>
1888 <td>[[{{{1}}}|{{{2}}}]]
1889 </td></tr></table>
1890
1891 !! end
1892
1893 !! test
1894 Magic variable as template parameter
1895 !! input
1896 {{paramtest|param={{SITENAME}}}}
1897 !! result
1898 <p>This is a test template with parameter MediaWiki
1899 </p>
1900 !! end
1901
1902 !! article
1903 Template:linktest
1904 !! text
1905 [[{{{param}}}|link]]
1906 !! endarticle
1907
1908 !! test
1909 Template parameter as link source
1910 !! input
1911 {{linktest|param=Main Page}}
1912 !! result
1913 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1914 </p>
1915 !! end
1916
1917
1918 !!article
1919 Template:paramtest2
1920 !! text
1921 including another template, {{paramtest|param={{{arg}}}}}
1922 !! endarticle
1923
1924 !! test
1925 Template passing argument to another template
1926 !! input
1927 {{paramtest2|arg='hmm'}}
1928 !! result
1929 <p>including another template, This is a test template with parameter 'hmm'
1930 </p>
1931 !! end
1932
1933 !! article
1934 Template:Linktest2
1935 !! text
1936 Main Page
1937 !! endarticle
1938
1939 !! test
1940 Template as link source
1941 !! input
1942 [[{{linktest2}}]]
1943 !! result
1944 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1945 </p>
1946 !! end
1947
1948
1949 !! article
1950 Template:loop1
1951 !! text
1952 {{loop2}}
1953 !! endarticle
1954
1955 !! article
1956 Template:loop2
1957 !! text
1958 {{loop1}}
1959 !! endarticle
1960
1961 !! test
1962 Template infinite loop
1963 !! input
1964 {{loop1}}
1965 !! result
1966 <p>{{loop1}}<!-- WARNING: template loop detected -->
1967 </p>
1968 !! end
1969
1970 !! test
1971 Template from main namespace
1972 !! input
1973 {{:Main Page}}
1974 !! result
1975 <p>blah blah
1976 </p>
1977 !! end
1978
1979 !! article
1980 Template:table
1981 !! text
1982 {|
1983 | 1 || 2
1984 |-
1985 | 3 || 4
1986 |}
1987 !! endarticle
1988
1989 !! test
1990 BUG 529: Template with table, not included at beginning of line
1991 !! input
1992 foo {{table}}
1993 !! result
1994 <p>foo
1995 </p>
1996 <table>
1997 <tr>
1998 <td> 1 </td><td> 2
1999 </td></tr>
2000 <tr>
2001 <td> 3 </td><td> 4
2002 </td></tr></table>
2003
2004 !! end
2005
2006 !! test
2007 BUG 523: Template shouldn't eat newline (or add an extra one before table)
2008 !! input
2009 foo
2010 {{table}}
2011 !! result
2012 <p>foo
2013 </p>
2014 <table>
2015 <tr>
2016 <td> 1 </td><td> 2
2017 </td></tr>
2018 <tr>
2019 <td> 3 </td><td> 4
2020 </td></tr></table>
2021
2022 !! end
2023
2024 !! test
2025 BUG 41: Template parameters shown as broken links
2026 !! input
2027 {{{parameter}}}
2028 !! result
2029 <p>{{{parameter}}}
2030 </p>
2031 !! end
2032
2033
2034 !! article
2035 Template:MSGNW test
2036 !! text
2037 ''None'' of '''this''' should be
2038 * interepreted
2039 but rather passed unmodified
2040 {{test}}
2041 !! endarticle
2042
2043 # hmm, fix this or just deprecate msgnw and document its behavior?
2044 !! test
2045 msgnw keyword
2046 !! options
2047 disabled
2048 !! input
2049 {{msgnw:MSGNW test}}
2050 !! result
2051 <p>''None'' of '''this''' should be
2052 * interepreted
2053 but rather passed unmodified
2054 {{test}}
2055 </p>
2056 !! end
2057
2058 !! test
2059 int keyword
2060 !! input
2061 {{int:youhavenewmessages|lots of money|not!}}
2062 !! result
2063 <p>You have lots of money (not!).
2064 </p>
2065 !! end
2066
2067 !! article
2068 Template:Includes
2069 !! text
2070 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2071 !! endarticle
2072
2073 !! test
2074 <includeonly> and <noinclude> being included
2075 !! input
2076 {{Includes}}
2077 !! result
2078 <p>Foobar
2079 </p>
2080 !! end
2081
2082 !! article
2083 Template:Includes2
2084 !! text
2085 <onlyinclude>Foo</onlyinclude>bar
2086 !! endarticle
2087
2088 !! test
2089 <onlyinclude> being included
2090 !! input
2091 {{Includes2}}
2092 !! result
2093 <p>Foo
2094 </p>
2095 !! end
2096
2097
2098 !! article
2099 Template:Includes3
2100 !! text
2101 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
2102 !! endarticle
2103
2104 !! test
2105 <onlyinclude> and <includeonly> being included
2106 !! input
2107 {{Includes3}}
2108 !! result
2109 <p>Foo
2110 </p>
2111 !! end
2112
2113 !! test
2114 <includeonly> and <noinclude> on a page
2115 !! input
2116 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2117 !! result
2118 <p>Foozar
2119 </p>
2120 !! end
2121
2122 !! test
2123 <onlyinclude> on a page
2124 !! input
2125 <onlyinclude>Foo</onlyinclude>bar
2126 !! result
2127 <p>Foobar
2128 </p>
2129 !! end
2130
2131 ###
2132 ### Pre-save transform tests
2133 ###
2134 !! test
2135 pre-save transform: subst:
2136 !! options
2137 PST
2138 !! input
2139 {{subst:test}}
2140 !! result
2141 This is a test template
2142 !! end
2143
2144 !! test
2145 pre-save transform: normal template
2146 !! options
2147 PST
2148 !! input
2149 {{test}}
2150 !! result
2151 {{test}}
2152 !! end
2153
2154 !! test
2155 pre-save transform: nonexistant template
2156 !! options
2157 PST
2158 !! input
2159 {{thistemplatedoesnotexist}}
2160 !! result
2161 {{thistemplatedoesnotexist}}
2162 !! end
2163
2164
2165 !! test
2166 pre-save transform: subst magic variables
2167 !! options
2168 PST
2169 !! input
2170 {{subst:SITENAME}}
2171 !! result
2172 MediaWiki
2173 !! end
2174
2175 # This is bug 89, which I fixed. -- wtm
2176 !! test
2177 pre-save transform: subst: templates with parameters
2178 !! options
2179 pst
2180 !! input
2181 {{subst:paramtest|param="something else"}}
2182 !! result
2183 This is a test template with parameter "something else"
2184 !! end
2185
2186 !! article
2187 Template:nowikitest
2188 !! text
2189 <nowiki>'''not wiki'''</nowiki>
2190 !! endarticle
2191
2192 !! test
2193 pre-save transform: nowiki in subst (bug 1188)
2194 !! options
2195 pst
2196 !! input
2197 {{subst:nowikitest}}
2198 !! result
2199 <nowiki>'''not wiki'''</nowiki>
2200 !! end
2201
2202
2203 !! article
2204 Template:commenttest
2205 !! text
2206 This template has <!-- a comment --> in it.
2207 !! endarticle
2208
2209 !! test
2210 pre-save transform: comment in subst (bug 1936)
2211 !! options
2212 pst
2213 !! input
2214 {{subst:commenttest}}
2215 !! result
2216 This template has <!-- a comment --> in it.
2217 !! end
2218
2219
2220 !! article
2221 Template:dangerous
2222 !!text
2223 <span onmouseover="alert('crap')">Oh no</span>
2224 !!endarticle
2225
2226 !!test
2227 (confirming safety of fix for subst bug 1936)
2228 !! input
2229 {{Template:dangerous}}
2230 !! result
2231 <p><span>Oh no</span>
2232 </p>
2233 !! end
2234
2235 !! test
2236 pre-save transform: comment containing gallery (bug 5024)
2237 !! options
2238 pst
2239 !! input
2240 <!-- <gallery>data</gallery> -->
2241 !!result
2242 <!-- <gallery>data</gallery> -->
2243 !!end
2244
2245 !! test
2246 pre-save transform: comment containing extension
2247 !! options
2248 pst
2249 !! input
2250 <!-- <tag>data</tag> -->
2251 !!result
2252 <!-- <tag>data</tag> -->
2253 !!end
2254
2255 !! test
2256 pre-save transform: comment containing nowiki
2257 !! options
2258 pst
2259 !! input
2260 <!-- <nowiki>data</nowiki> -->
2261 !!result
2262 <!-- <nowiki>data</nowiki> -->
2263 !!end
2264
2265 !! test
2266 pre-save transform: comment containing math
2267 !! options
2268 pst
2269 !! input
2270 <!-- <math>data</math> -->
2271 !!result
2272 <!-- <math>data</math> -->
2273 !!end
2274
2275
2276 ###
2277 ### Message transform tests
2278 ###
2279 !! test
2280 message transform: magic variables
2281 !! options
2282 msg
2283 !! input
2284 {{SITENAME}}
2285 !! result
2286 MediaWiki
2287 !! end
2288
2289 !! test
2290 message transform: should not transform wiki markup
2291 !! options
2292 msg
2293 !! input
2294 ''test''
2295 !! result
2296 ''test''
2297 !! end
2298
2299 ###
2300 ### Images
2301 ###
2302 !! test
2303 Simple image
2304 !! input
2305 [[Image:foobar.jpg]]
2306 !! result
2307 <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>
2308 </p>
2309 !! end
2310
2311 !! test
2312 Right-aligned image
2313 !! input
2314 [[Image:foobar.jpg|right]]
2315 !! result
2316 <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>
2317
2318 !! end
2319
2320 !! test
2321 Image with caption
2322 !! input
2323 [[Image:foobar.jpg|right|Caption text]]
2324 !! result
2325 <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>
2326
2327 !! end
2328
2329 !! test
2330 Image with frame and link
2331 !! input
2332 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
2333 !! result
2334 <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>
2335
2336 !! end
2337
2338 !! test
2339 Link to image page
2340 !! input
2341 [[:Image:test]]
2342 !! result
2343 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
2344 </p>
2345 !! end
2346
2347 !! test
2348 Frameless image caption with a free URL
2349 !! input
2350 [[Image:foobar.jpg|http://example.com]]
2351 !! result
2352 <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>
2353 </p>
2354 !! end
2355
2356 !! test
2357 Thumbnail image caption with a free URL
2358 !! input
2359 [[Image:foobar.jpg|thumb|http://example.com]]
2360 !! result
2361 <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>
2362
2363 !! end
2364
2365 !! test
2366 BUG 1887: A ISBN with a thumbnail
2367 !! input
2368 [[Image:foobar.jpg|thumb|ISBN 12354]]
2369 !! result
2370 <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>
2371 !! end
2372
2373 !! test
2374 BUG 1887: A <math> with a thumbnail
2375 !! input
2376 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2377 !! result
2378 <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>
2379 !! end
2380
2381 # Pending resolution to bug 368
2382 !! test
2383 BUG 648: Frameless image caption with a link
2384 !! input
2385 [[Image:foobar.jpg|text with a [[link]] in it]]
2386 !! result
2387 <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>
2388 </p>
2389 !! end
2390
2391 !! test
2392 BUG 648: Frameless image caption with a link (suffix)
2393 !! input
2394 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2395 !! result
2396 <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>
2397 </p>
2398 !! end
2399
2400 !! test
2401 BUG 648: Frameless image caption with an interwiki link
2402 !! input
2403 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2404 !! result
2405 <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>
2406 </p>
2407 !! end
2408
2409 !! test
2410 BUG 648: Frameless image caption with a piped interwiki link
2411 !! input
2412 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2413 !! result
2414 <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>
2415 </p>
2416 !! end
2417
2418 !! test
2419 Escape HTML special chars in image alt text
2420 !! input
2421 [[Image:foobar.jpg|& < > "]]
2422 !! result
2423 <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>
2424 </p>
2425 !! end
2426
2427 !! test
2428 BUG 499: Alt text should have &#1234;, not &amp;1234;
2429 !! input
2430 [[Image:foobar.jpg|&#9792;]]
2431 !! result
2432 <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>
2433 </p>
2434 !! end
2435
2436 !! test
2437 Broken image caption with link
2438 !! input
2439 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2440 !! result
2441 <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.
2442 </p>
2443 !! end
2444
2445 !! test
2446 Image caption containing another image
2447 !! input
2448 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2449 !! result
2450 <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>
2451
2452 !! end
2453
2454 !! test
2455 Image caption containing a newline
2456 !! input
2457 [[Image:Foobar.jpg|This
2458 *is some text]]
2459 !! result
2460 <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>
2461 </p>
2462 !!end
2463
2464
2465 !! test
2466 Bug 3090: External links other than http: in image captions
2467 !! input
2468 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2469 !! result
2470 <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>
2471
2472 !! end
2473
2474
2475 ###
2476 ### Subpages
2477 ###
2478 !! article
2479 Subpage test/subpage
2480 !! text
2481 foo
2482 !! endarticle
2483
2484 !! test
2485 Subpage link
2486 !! options
2487 subpage title=[[Subpage test]]
2488 !! input
2489 [[/subpage]]
2490 !! result
2491 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2492 </p>
2493 !! end
2494
2495 !! test
2496 Subpage noslash link
2497 !! options
2498 subpage title=[[Subpage test]]
2499 !!input
2500 [[/subpage/]]
2501 !! result
2502 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2503 </p>
2504 !! end
2505
2506 !! test
2507 Disabled subpages
2508 !! input
2509 [[/subpage]]
2510 !! result
2511 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2512 </p>
2513 !! end
2514
2515 !! test
2516 BUG 561: {{/Subpage}}
2517 !! options
2518 subpage title=[[Page]]
2519 !! input
2520 {{/Subpage}}
2521 !! result
2522 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2523 </p>
2524 !! end
2525
2526 ###
2527 ### Categories
2528 ###
2529 !! article
2530 Category:MediaWiki User's Guide
2531 !! text
2532 blah
2533 !! endarticle
2534
2535 !! test
2536 Link to category
2537 !! input
2538 [[:Category:MediaWiki User's Guide]]
2539 !! result
2540 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2541 </p>
2542 !! end
2543
2544 !! test
2545 Simple category
2546 !! options
2547 cat
2548 !! input
2549 [[Category: MediaWiki User's Guide]]
2550 !! result
2551 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2552 !! end
2553
2554 ###
2555 ### Inter-language links
2556 ###
2557 !! test
2558 Inter-language links
2559 !! options
2560 ill
2561 !! input
2562 [[es:Alimento]]
2563 [[fr:Nourriture]]
2564 [[zh:&#39135;&#21697;]]
2565 !! result
2566 es:Alimento fr:Nourriture zh:食品
2567 !! end
2568
2569 ###
2570 ### Sections
2571 ###
2572 !! test
2573 Basic section headings
2574 !! options
2575 title=[[Parser test script]]
2576 !! input
2577 == Headline 1 ==
2578 Some text
2579
2580 ==Headline 2==
2581 More
2582 ===Smaller headline===
2583 Blah blah
2584 !! result
2585 <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>
2586 <p>Some text
2587 </p>
2588 <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>
2589 <p>More
2590 </p>
2591 <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>
2592 <p>Blah blah
2593 </p>
2594 !! end
2595
2596 !! test
2597 Section headings with TOC
2598 !! options
2599 title=[[Parser test script]]
2600 !! input
2601 == Headline 1 ==
2602 === Subheadline 1 ===
2603 ===== Skipping a level =====
2604 ====== Skipping a level ======
2605
2606 == Headline 2 ==
2607 Some text
2608 ===Another headline===
2609 !! result
2610 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2611 <ul>
2612 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2613 <ul>
2614 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2615 <ul>
2616 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2617 <ul>
2618 <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>
2619 </ul>
2620 </li>
2621 </ul>
2622 </li>
2623 </ul>
2624 </li>
2625 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2626 <ul>
2627 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2628 </ul>
2629 </li>
2630 </ul>
2631 </td></tr></table>
2632 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2633 <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>
2634 <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>
2635 <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>
2636 <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>
2637 <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>
2638 <p>Some text
2639 </p>
2640 <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>
2641
2642 !! end
2643
2644 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2645 !! test
2646 Handling of sections up to level 6 and beyond
2647 !! input
2648 = Level 1 Heading=
2649 == Level 2 Heading==
2650 === Level 3 Heading===
2651 ==== Level 4 Heading====
2652 ===== Level 5 Heading=====
2653 ====== Level 6 Heading======
2654 ======= Level 7 Heading=======
2655 ======== Level 8 Heading========
2656 ========= Level 9 Heading=========
2657 ========== Level 10 Heading==========
2658 !! result
2659 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2660 <ul>
2661 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2662 <ul>
2663 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2664 <ul>
2665 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2666 <ul>
2667 <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>
2668 <ul>
2669 <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>
2670 <ul>
2671 <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>
2672 <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>
2673 <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>
2674 <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>
2675 <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>
2676 </ul>
2677 </li>
2678 </ul>
2679 </li>
2680 </ul>
2681 </li>
2682 </ul>
2683 </li>
2684 </ul>
2685 </li>
2686 </ul>
2687 </td></tr></table>
2688 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2689 </p>
2690 <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>
2691 <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>
2692 <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>
2693 <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>
2694 <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>
2695 <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>
2696 <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>
2697 <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>
2698 <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>
2699 <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>
2700
2701 !! end
2702
2703 !! test
2704 Resolving duplicate section names
2705 !! options
2706 title=[[Parser test script]]
2707 !! input
2708 == Foo bar ==
2709 == Foo bar ==
2710 !! result
2711 <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>
2712 <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>
2713
2714 !! end
2715
2716 !! article
2717 Template:sections
2718 !! text
2719 ===Section 1===
2720 ==Section 2==
2721 !! endarticle
2722
2723 !! test
2724 Template with sections, __NOTOC__
2725 !! options
2726 title=[[Parser test script]]
2727 !! input
2728 __NOTOC__
2729 ==Section 0==
2730 {{sections}}
2731 ==Section 4==
2732 !! result
2733 <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>
2734 <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>
2735 <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>
2736 <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>
2737
2738 !! end
2739
2740 !! test
2741 __NOEDITSECTION__ keyword
2742 !! input
2743 __NOEDITSECTION__
2744 ==Section 1==
2745 ==Section 2==
2746 !! result
2747 <a name="Section_1"></a><h2>Section 1</h2>
2748 <a name="Section_2"></a><h2>Section 2</h2>
2749
2750 !! end
2751
2752 !! test
2753 Link inside a section heading
2754 !! options
2755 title=[[Parser test script]]
2756 !! input
2757 ==Section with a [[Main Page|link]] in it==
2758 !! result
2759 <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>
2760
2761 !! end
2762
2763
2764 !! test
2765 BUG 1219 URL next to image (good)
2766 !! input
2767 http://example.com [[Image:foobar.jpg]]
2768 !! result
2769 <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>
2770 </p>
2771 !!end
2772
2773 !! test
2774 BUG 1219 URL next to image (broken)
2775 !! input
2776 http://example.com[[Image:foobar.jpg]]
2777 !! result
2778 <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>
2779 </p>
2780 !!end
2781
2782 !! test
2783 Bug 1186 news: in the middle of text
2784 !! input
2785 http://en.wikinews.org/wiki/Wikinews:Workplace
2786 !! result
2787 <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>
2788 </p>
2789 !!end
2790
2791
2792 !! test
2793 Namespaced link must have a title
2794 !! input
2795 [[Project:]]
2796 !! result
2797 <p>[[Project:]]
2798 </p>
2799 !!end
2800
2801 !! test
2802 Namespaced link must have a title (bad fragment version)
2803 !! input
2804 [[Project:#fragment]]
2805 !! result
2806 <p>[[Project:#fragment]]
2807 </p>
2808 !!end
2809
2810
2811 !! test
2812 div with no attributes
2813 !! input
2814 <div>HTML rocks</div>
2815 !! result
2816 <div>HTML rocks</div>
2817
2818 !! end
2819
2820 !! test
2821 div with double-quoted attribute
2822 !! input
2823 <div id="rock">HTML rocks</div>
2824 !! result
2825 <div id="rock">HTML rocks</div>
2826
2827 !! end
2828
2829 !! test
2830 div with single-quoted attribute
2831 !! input
2832 <div id='rock'>HTML rocks</div>
2833 !! result
2834 <div id="rock">HTML rocks</div>
2835
2836 !! end
2837
2838 !! test
2839 div with unquoted attribute
2840 !! input
2841 <div id=rock>HTML rocks</div>
2842 !! result
2843 <div id="rock">HTML rocks</div>
2844
2845 !! end
2846
2847 !! test
2848 div with illegal double attributes
2849 !! input
2850 <div align="center" align="right">HTML rocks</div>
2851 !! result
2852 <div align="right">HTML rocks</div>
2853
2854 !!end
2855
2856 !! test
2857 HTML multiple attributes correction
2858 !! input
2859 <p class="error" class="awesome">Awesome!</p>
2860 !! result
2861 <p class="awesome">Awesome!</p>
2862
2863 !!end
2864
2865 !! test
2866 Table multiple attributes correction
2867 !! input
2868 {|
2869 !+ class="error" class="awesome"| status
2870 |}
2871 !! result
2872 <table>
2873 <tr>
2874 <th class="awesome"> status
2875 </th></tr></table>
2876
2877 !!end
2878
2879 !! test
2880 DIV IN UPPERCASE
2881 !! input
2882 <DIV ALIGN="center">HTML ROCKS</DIV>
2883 !! result
2884 <div align="center">HTML ROCKS</div>
2885
2886 !!end
2887
2888
2889 !! test
2890 text with amp in the middle of nowhere
2891 !! input
2892 Remember AT&T?
2893 !!result
2894 <p>Remember AT&amp;T?
2895 </p>
2896 !! end
2897
2898 !! test
2899 text with character entity: eacute
2900 !! input
2901 I always thought &eacute; was a cute letter.
2902 !! result
2903 <p>I always thought &eacute; was a cute letter.
2904 </p>
2905 !! end
2906
2907 !! test
2908 text with undefined character entity: xacute
2909 !! input
2910 I always thought &xacute; was a cute letter.
2911 !! result
2912 <p>I always thought &amp;xacute; was a cute letter.
2913 </p>
2914 !! end
2915
2916
2917 ###
2918 ### Media links
2919 ###
2920
2921 !! test
2922 Media link
2923 !! input
2924 [[Media:Foobar.jpg]]
2925 !! result
2926 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2927 </p>
2928 !! end
2929
2930 !! test
2931 Media link with text
2932 !! input
2933 [[Media:Foobar.jpg|A neat file to look at]]
2934 !! result
2935 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2936 </p>
2937 !! end
2938
2939 # FIXME: this is still bad HTML tag nesting
2940 !! test
2941 Media link with nasty text
2942 !! input
2943 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2944 !! result
2945 <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>
2946 </p>
2947 !! end
2948
2949 !! test
2950 Media link to nonexistent file (bug 1702)
2951 !! input
2952 [[Media:No such.jpg]]
2953 !! result
2954 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2955 </p>
2956 !! end
2957
2958 !! test
2959 Image link to nonexistent file (bug 1850 - good)
2960 !! input
2961 [[Image:No such.jpg]]
2962 !! result
2963 <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>
2964 </p>
2965 !! end
2966
2967 !! test
2968 :Image link to nonexistent file (bug 1850 - bad)
2969 !! input
2970 [[:Image:No such.jpg]]
2971 !! result
2972 <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>
2973 </p>
2974 !! end
2975
2976
2977
2978 !! test
2979 Character reference normalization in link text (bug 1938)
2980 !! input
2981 [[Main Page|this&that]]
2982 !! result
2983 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2984 </p>
2985 !!end
2986
2987 !! test
2988 Empty attribute crash test (bug 2067)
2989 !! input
2990 <font color="">foo</font>
2991 !! result
2992 <p><font color="">foo</font>
2993 </p>
2994 !! end
2995
2996 !! test
2997 Empty attribute crash test single-quotes (bug 2067)
2998 !! input
2999 <font color=''>foo</font>
3000 !! result
3001 <p><font color="">foo</font>
3002 </p>
3003 !! end
3004
3005 !! test
3006 Attribute test: equals, then nothing
3007 !! input
3008 <font color=>foo</font>
3009 !! result
3010 <p><font>foo</font>
3011 </p>
3012 !! end
3013
3014 !! test
3015 Attribute test: unquoted value
3016 !! input
3017 <font color=x>foo</font>
3018 !! result
3019 <p><font color="x">foo</font>
3020 </p>
3021 !! end
3022
3023 !! test
3024 Attribute test: unquoted but illegal value (hash)
3025 !! input
3026 <font color=#x>foo</font>
3027 !! result
3028 <p><font color="#x">foo</font>
3029 </p>
3030 !! end
3031
3032 !! test
3033 Attribute test: no value
3034 !! input
3035 <font color>foo</font>
3036 !! result
3037 <p><font color="color">foo</font>
3038 </p>
3039 !! end
3040
3041 !! test
3042 Bug 2095: link with three closing brackets
3043 !! input
3044 [[Main Page]]]
3045 !! result
3046 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
3047 </p>
3048 !! end
3049
3050 !! test
3051 Bug 2095: link with pipe and three closing brackets
3052 !! input
3053 [[Main Page|link]]]
3054 !! result
3055 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
3056 </p>
3057 !! end
3058
3059
3060 ###
3061 ### Safety
3062 ###
3063
3064 !! article
3065 Template:Dangerous attribute
3066 !! text
3067 " onmouseover="alert(document.cookie)
3068 !! endarticle
3069
3070 !! article
3071 Template:Dangerous style attribute
3072 !! text
3073 border-size: expression(alert(document.cookie))
3074 !! endarticle
3075
3076 !! article
3077 Template:Div style
3078 !! text
3079 <div style="float: right; {{{1}}}">Magic div</div>
3080 !! endarticle
3081
3082 !! test
3083 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
3084 !! input
3085 <div title="{{test}}"></div>
3086 !! result
3087 <div title="This is a test template"></div>
3088
3089 !! end
3090
3091 !! test
3092 Bug 2304: HTML attribute safety (dangerous template; 2309)
3093 !! input
3094 <div title="{{dangerous attribute}}"></div>
3095 !! result
3096 <div title=""></div>
3097
3098 !! end
3099
3100 !! test
3101 Bug 2304: HTML attribute safety (dangerous style template; 2309)
3102 !! input
3103 <div style="{{dangerous style attribute}}"></div>
3104 !! result
3105 <div></div>
3106
3107 !! end
3108
3109 !! test
3110 Bug 2304: HTML attribute safety (safe parameter; 2309)
3111 !! input
3112 {{div style|width: 200px}}
3113 !! result
3114 <div style="float: right; width: 200px">Magic div</div>
3115
3116 !! end
3117
3118 !! test
3119 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
3120 !! input
3121 {{div style|width: expression(alert(document.cookie))}}
3122 !! result
3123 <div>Magic div</div>
3124
3125 !! end
3126
3127 !! test
3128 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
3129 !! input
3130 {{div style|"><script>alert(document.cookie)</script>}}
3131 !! result
3132 <div>Magic div</div>
3133
3134 !! end
3135
3136 !! test
3137 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
3138 !! input
3139 {{div style|" ><script>alert(document.cookie)</script>}}
3140 !! result
3141 <div style="float: right; ">Magic div</div>
3142
3143 !! end
3144
3145 !! test
3146 Bug 2304: HTML attribute safety (link)
3147 !! input
3148 <div title="[[Main Page]]"></div>
3149 !! result
3150 <div title="&#91;&#91;Main Page]]"></div>
3151
3152 !! end
3153
3154 !! test
3155 Bug 2304: HTML attribute safety (italics)
3156 !! input
3157 <div title="''foobar''"></div>
3158 !! result
3159 <div title="&#39;&#39;foobar&#39;&#39;"></div>
3160
3161 !! end
3162
3163 !! test
3164 Bug 2304: HTML attribute safety (bold)
3165 !! input
3166 <div title="'''foobar'''"></div>
3167 !! result
3168 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
3169
3170 !! end
3171
3172
3173 !! test
3174 Bug 2304: HTML attribute safety (ISBN)
3175 !! input
3176 <div title="ISBN 1234567890"></div>
3177 !! result
3178 <div title="&#73;SBN 1234567890"></div>
3179
3180 !! end
3181
3182 !! test
3183 Bug 2304: HTML attribute safety (RFC)
3184 !! input
3185 <div title="RFC 1234"></div>
3186 !! result
3187 <div title="&#82;FC 1234"></div>
3188
3189 !! end
3190
3191 !! test
3192 Bug 2304: HTML attribute safety (PMID)
3193 !! input
3194 <div title="PMID 1234567890"></div>
3195 !! result
3196 <div title="&#80;MID 1234567890"></div>
3197
3198 !! end
3199
3200 !! test
3201 Bug 2304: HTML attribute safety (web link)
3202 !! input
3203 <div title="http://example.com/"></div>
3204 !! result
3205 <div title="http&#58;//example.com/"></div>
3206
3207 !! end
3208
3209 !! test
3210 Bug 2304: HTML attribute safety (named web link)
3211 !! input
3212 <div title="[http://example.com/ link]"></div>
3213 !! result
3214 <div title="&#91;http&#58;//example.com/ link]"></div>
3215
3216 !! end
3217
3218 !! test
3219 Bug 3244: HTML attribute safety (extension; safe)
3220 !! input
3221 <div style="<nowiki>background:blue</nowiki>"></div>
3222 !! result
3223 <div style="background:blue"></div>
3224
3225 !! end
3226
3227 !! test
3228 Bug 3244: HTML attribute safety (extension; unsafe)
3229 !! input
3230 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
3231 !! result
3232 <div></div>
3233
3234 !! end
3235
3236 !! test
3237 Math section safety when disabled
3238 !! input
3239 <math><script>alert(document.cookies);</script></math>
3240 !! result
3241 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
3242 </p>
3243 !! end
3244
3245 # More MSIE fun discovered by Tom Gilder
3246
3247 !! test
3248 MSIE CSS safety test: spurious slash
3249 !! input
3250 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
3251 !! result
3252 <div>evil</div>
3253
3254 !! end
3255
3256 !! test
3257 MSIE CSS safety test: hex code
3258 !! input
3259 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3260 !! result
3261 <div>evil</div>
3262
3263 !! end
3264
3265 !! test
3266 MSIE CSS safety test: comment in url
3267 !! input
3268 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3269 !! result
3270 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3271
3272 !! end
3273
3274 !! test
3275 MSIE CSS safety test: comment in expression
3276 !! input
3277 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3278 !! result
3279 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3280
3281 !! end
3282
3283
3284 !! test
3285 Table attribute legitimate extension
3286 !! input
3287 {|
3288 !+ style="<nowiki>color:blue</nowiki>"| status
3289 |}
3290 !! result
3291 <table>
3292 <tr>
3293 <th style="color:blue"> status
3294 </th></tr></table>
3295
3296 !!end
3297
3298 !! test
3299 Table attribute safety
3300 !! input
3301 {|
3302 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
3303 |}
3304 !! result
3305 <table>
3306 <tr>
3307 <th> status
3308 </th></tr></table>
3309
3310 !! end
3311
3312 ###
3313 ### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
3314 ###
3315 !! test
3316 Parser hook: empty input
3317 !! input
3318 <tag></tag>
3319 !! result
3320 <pre>
3321 string(0) ""
3322 array(0) {
3323 }
3324 </pre>
3325
3326 !! end
3327
3328 !! test
3329 Parser hook: empty input using terminated empty elements
3330 !! input
3331 <tag/>
3332 !! result
3333 <pre>
3334 NULL
3335 array(0) {
3336 }
3337 </pre>
3338
3339 !! end
3340
3341 !! test
3342 Parser hook: basic input
3343 !! input
3344 <tag>input</tag>
3345 !! result
3346 <pre>
3347 string(5) "input"
3348 array(0) {
3349 }
3350 </pre>
3351
3352 !! end
3353
3354
3355 !! test
3356 Parser hook: case insensetive
3357 !! input
3358 <TAG>input</TAG>
3359 !! result
3360 <pre>
3361 string(5) "input"
3362 array(0) {
3363 }
3364 </pre>
3365
3366 !! end
3367
3368
3369 !! test
3370 Parser hook: case insensetive, redux
3371 !! input
3372 <TaG>input</TAg>
3373 !! result
3374 <pre>
3375 string(5) "input"
3376 array(0) {
3377 }
3378 </pre>
3379
3380 !! end
3381
3382 !! test
3383 Parser hook: nested tags
3384 !! options
3385 noxml
3386 !! input
3387 <tag><tag></tag></tag>
3388 !! result
3389 <pre>
3390 string(5) "<tag>"
3391 array(0) {
3392 }
3393 </pre>&lt;/tag&gt;
3394
3395 !! end
3396
3397 !! test
3398 Parser hook: basic arguments
3399 !! input
3400 <tag width=200 height = "100" depth = '50' square></tag>
3401 !! result
3402 <pre>
3403 string(0) ""
3404 array(4) {
3405 ["width"]=>
3406 string(3) "200"
3407 ["height"]=>
3408 string(3) "100"
3409 ["depth"]=>
3410 string(2) "50"
3411 ["square"]=>
3412 string(6) "square"
3413 }
3414 </pre>
3415
3416 !! end
3417
3418 !! test
3419 Parser hook: empty input using terminated empty elements (bug 2374)
3420 !! input
3421 <tag foo=bar/>text
3422 !! result
3423 <pre>
3424 NULL
3425 array(1) {
3426 ["foo"]=>
3427 string(3) "bar"
3428 }
3429 </pre>text
3430
3431 !! end
3432
3433 # </tag> should be output literally since there is no matching tag that begins it
3434 !! test
3435 Parser hook: basic arguments using terminated empty elements (bug 2374)
3436 !! input
3437 <tag width=200 height = "100" depth = '50' square/>
3438 other stuff
3439 </tag>
3440 !! result
3441 <pre>
3442 NULL
3443 array(4) {
3444 ["width"]=>
3445 string(3) "200"
3446 ["height"]=>
3447 string(3) "100"
3448 ["depth"]=>
3449 string(2) "50"
3450 ["square"]=>
3451 string(6) "square"
3452 }
3453 </pre>
3454 <p>other stuff
3455 &lt;/tag&gt;
3456 </p>
3457 !! end
3458
3459 ###
3460 ### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
3461 ###
3462
3463 !! test
3464 Parser hook: static parser hook not inside a comment
3465 !! input
3466 <statictag>hello, world</statictag>
3467 <statictag action=flush/>
3468 !! result
3469 <p>hello, world
3470 </p>
3471 !! end
3472
3473
3474 !! test
3475 Parser hook: static parser hook inside a comment
3476 !! input
3477 <!-- <statictag>hello, world</statictag> -->
3478 <statictag action=flush/>
3479 !! result
3480 <p><br />
3481 </p>
3482 !! end
3483
3484 # Nested template calls; this case was broken by Parser.php rev 1.506,
3485 # since reverted.
3486
3487 !! article
3488 Template:One-parameter
3489 !! text
3490 (My parameter is: {{{1}}})
3491 !! endarticle
3492
3493 !! article
3494 Template:Map-one-parameter
3495 !! text
3496 {{{{{1}}}|{{{2}}}}}
3497 !! endarticle
3498
3499 !! test
3500 Nested template calls
3501 !! input
3502 {{Map-one-parameter|One-parameter|param}}
3503 !! result
3504 <p>(My parameter is: param)
3505 </p>
3506 !! end
3507
3508
3509 ###
3510 ### Sanitizer
3511 ###
3512 !! test
3513 Sanitizer: Closing of open tags
3514 !! input
3515 <s></s><table></table>
3516 !! result
3517 <s></s><table></table>
3518
3519 !! end
3520
3521 !! test
3522 Sanitizer: Closing of open but not closed tags
3523 !! input
3524 <s>foo
3525 !! result
3526 <p><s>foo</s>
3527 </p>
3528 !! end
3529
3530 !! test
3531 Sanitizer: Closing of closed but not open tags
3532 !! input
3533 </s>
3534 !! result
3535 <p>&lt;/s&gt;
3536 </p>
3537 !! end
3538
3539 !! test
3540 Sanitizer: Closing of closed but not open table tags
3541 !! input
3542 Table not started</td></tr></table>
3543 !! result
3544 <p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
3545 </p>
3546 !! end
3547
3548 !! test
3549 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
3550 !! input
3551 <span id="æ: v">byte</span>[[#æ: v|backlink]]
3552 !! result
3553 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
3554 </p>
3555 !! end
3556
3557 !! test
3558 Sanitizer: Validating the contents of the id attribute (bug 4515)
3559 !! input
3560 <br id=9 />
3561 !! result
3562 Something, but defenetly not <br id="9" />...
3563 !! end
3564
3565 TODO:
3566 more images
3567 more tables
3568 math
3569 character entities
3570 and much more