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