e4747785f624665fa351e8f1ba85be2ddf52f0f9
[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 extension (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 nowiki
2238 !! options
2239 pst
2240 !! input
2241 <!-- <nowiki>data</nowiki> -->
2242 !!result
2243 <!-- <nowiki>data</nowiki> -->
2244 !!end
2245
2246 !! test
2247 pre-save transform: comment containing math
2248 !! options
2249 pst
2250 !! input
2251 <!-- <math>data</math> -->
2252 !!result
2253 <!-- <math>data</math> -->
2254 !!end
2255
2256
2257 ###
2258 ### Message transform tests
2259 ###
2260 !! test
2261 message transform: magic variables
2262 !! options
2263 msg
2264 !! input
2265 {{SITENAME}}
2266 !! result
2267 MediaWiki
2268 !! end
2269
2270 !! test
2271 message transform: should not transform wiki markup
2272 !! options
2273 msg
2274 !! input
2275 ''test''
2276 !! result
2277 ''test''
2278 !! end
2279
2280 ###
2281 ### Images
2282 ###
2283 !! test
2284 Simple image
2285 !! input
2286 [[Image:foobar.jpg]]
2287 !! result
2288 <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>
2289 </p>
2290 !! end
2291
2292 !! test
2293 Right-aligned image
2294 !! input
2295 [[Image:foobar.jpg|right]]
2296 !! result
2297 <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>
2298
2299 !! end
2300
2301 !! test
2302 Image with caption
2303 !! input
2304 [[Image:foobar.jpg|right|Caption text]]
2305 !! result
2306 <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>
2307
2308 !! end
2309
2310 !! test
2311 Image with frame and link
2312 !! input
2313 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
2314 !! result
2315 <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>
2316
2317 !! end
2318
2319 !! test
2320 Link to image page
2321 !! input
2322 [[:Image:test]]
2323 !! result
2324 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
2325 </p>
2326 !! end
2327
2328 !! test
2329 Frameless image caption with a free URL
2330 !! input
2331 [[Image:foobar.jpg|http://example.com]]
2332 !! result
2333 <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>
2334 </p>
2335 !! end
2336
2337 !! test
2338 Thumbnail image caption with a free URL
2339 !! input
2340 [[Image:foobar.jpg|thumb|http://example.com]]
2341 !! result
2342 <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>
2343
2344 !! end
2345
2346 !! test
2347 BUG 1887: A ISBN with a thumbnail
2348 !! input
2349 [[Image:foobar.jpg|thumb|ISBN 12354]]
2350 !! result
2351 <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>
2352 !! end
2353
2354 !! test
2355 BUG 1887: A <math> with a thumbnail
2356 !! input
2357 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2358 !! result
2359 <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>
2360 !! end
2361
2362 # Pending resolution to bug 368
2363 !! test
2364 BUG 648: Frameless image caption with a link
2365 !! input
2366 [[Image:foobar.jpg|text with a [[link]] in it]]
2367 !! result
2368 <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>
2369 </p>
2370 !! end
2371
2372 !! test
2373 BUG 648: Frameless image caption with a link (suffix)
2374 !! input
2375 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2376 !! result
2377 <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>
2378 </p>
2379 !! end
2380
2381 !! test
2382 BUG 648: Frameless image caption with an interwiki link
2383 !! input
2384 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2385 !! result
2386 <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>
2387 </p>
2388 !! end
2389
2390 !! test
2391 BUG 648: Frameless image caption with a piped interwiki link
2392 !! input
2393 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2394 !! result
2395 <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>
2396 </p>
2397 !! end
2398
2399 !! test
2400 Escape HTML special chars in image alt text
2401 !! input
2402 [[Image:foobar.jpg|& < > "]]
2403 !! result
2404 <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>
2405 </p>
2406 !! end
2407
2408 !! test
2409 BUG 499: Alt text should have &#1234;, not &amp;1234;
2410 !! input
2411 [[Image:foobar.jpg|&#9792;]]
2412 !! result
2413 <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>
2414 </p>
2415 !! end
2416
2417 !! test
2418 Broken image caption with link
2419 !! input
2420 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2421 !! result
2422 <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.
2423 </p>
2424 !! end
2425
2426 !! test
2427 Image caption containing another image
2428 !! input
2429 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2430 !! result
2431 <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>
2432
2433 !! end
2434
2435 !! test
2436 Image caption containing a newline
2437 !! input
2438 [[Image:Foobar.jpg|This
2439 *is some text]]
2440 !! result
2441 <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>
2442 </p>
2443 !!end
2444
2445
2446 !! test
2447 Bug 3090: External links other than http: in image captions
2448 !! input
2449 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2450 !! result
2451 <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>
2452
2453 !! end
2454
2455
2456 ###
2457 ### Subpages
2458 ###
2459 !! article
2460 Subpage test/subpage
2461 !! text
2462 foo
2463 !! endarticle
2464
2465 !! test
2466 Subpage link
2467 !! options
2468 subpage title=[[Subpage test]]
2469 !! input
2470 [[/subpage]]
2471 !! result
2472 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2473 </p>
2474 !! end
2475
2476 !! test
2477 Subpage noslash link
2478 !! options
2479 subpage title=[[Subpage test]]
2480 !!input
2481 [[/subpage/]]
2482 !! result
2483 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2484 </p>
2485 !! end
2486
2487 !! test
2488 Disabled subpages
2489 !! input
2490 [[/subpage]]
2491 !! result
2492 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2493 </p>
2494 !! end
2495
2496 !! test
2497 BUG 561: {{/Subpage}}
2498 !! options
2499 subpage title=[[Page]]
2500 !! input
2501 {{/Subpage}}
2502 !! result
2503 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2504 </p>
2505 !! end
2506
2507 ###
2508 ### Categories
2509 ###
2510 !! article
2511 Category:MediaWiki User's Guide
2512 !! text
2513 blah
2514 !! endarticle
2515
2516 !! test
2517 Link to category
2518 !! input
2519 [[:Category:MediaWiki User's Guide]]
2520 !! result
2521 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2522 </p>
2523 !! end
2524
2525 !! test
2526 Simple category
2527 !! options
2528 cat
2529 !! input
2530 [[Category: MediaWiki User's Guide]]
2531 !! result
2532 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2533 !! end
2534
2535 ###
2536 ### Inter-language links
2537 ###
2538 !! test
2539 Inter-language links
2540 !! options
2541 ill
2542 !! input
2543 [[es:Alimento]]
2544 [[fr:Nourriture]]
2545 [[zh:&#39135;&#21697;]]
2546 !! result
2547 es:Alimento fr:Nourriture zh:食品
2548 !! end
2549
2550 ###
2551 ### Sections
2552 ###
2553 !! test
2554 Basic section headings
2555 !! options
2556 title=[[Parser test script]]
2557 !! input
2558 == Headline 1 ==
2559 Some text
2560
2561 ==Headline 2==
2562 More
2563 ===Smaller headline===
2564 Blah blah
2565 !! result
2566 <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>
2567 <p>Some text
2568 </p>
2569 <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>
2570 <p>More
2571 </p>
2572 <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>
2573 <p>Blah blah
2574 </p>
2575 !! end
2576
2577 !! test
2578 Section headings with TOC
2579 !! options
2580 title=[[Parser test script]]
2581 !! input
2582 == Headline 1 ==
2583 === Subheadline 1 ===
2584 ===== Skipping a level =====
2585 ====== Skipping a level ======
2586
2587 == Headline 2 ==
2588 Some text
2589 ===Another headline===
2590 !! result
2591 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2592 <ul>
2593 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2594 <ul>
2595 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2596 <ul>
2597 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2598 <ul>
2599 <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>
2600 </ul>
2601 </li>
2602 </ul>
2603 </li>
2604 </ul>
2605 </li>
2606 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2607 <ul>
2608 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2609 </ul>
2610 </li>
2611 </ul>
2612 </td></tr></table>
2613 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2614 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
2615 <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>
2616 <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>
2617 <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>
2618 <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>
2619 <p>Some text
2620 </p>
2621 <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>
2622
2623 !! end
2624
2625 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2626 !! test
2627 Handling of sections up to level 6 and beyond
2628 !! input
2629 = Level 1 Heading=
2630 == Level 2 Heading==
2631 === Level 3 Heading===
2632 ==== Level 4 Heading====
2633 ===== Level 5 Heading=====
2634 ====== Level 6 Heading======
2635 ======= Level 7 Heading=======
2636 ======== Level 8 Heading========
2637 ========= Level 9 Heading=========
2638 ========== Level 10 Heading==========
2639 !! result
2640 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2641 <ul>
2642 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2643 <ul>
2644 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2645 <ul>
2646 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2647 <ul>
2648 <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>
2649 <ul>
2650 <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>
2651 <ul>
2652 <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>
2653 <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>
2654 <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>
2655 <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>
2656 <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>
2657 </ul>
2658 </li>
2659 </ul>
2660 </li>
2661 </ul>
2662 </li>
2663 </ul>
2664 </li>
2665 </ul>
2666 </li>
2667 </ul>
2668 </td></tr></table>
2669 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2670 </p>
2671 <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>
2672 <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>
2673 <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>
2674 <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>
2675 <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>
2676 <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>
2677 <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>
2678 <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>
2679 <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>
2680 <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>
2681
2682 !! end
2683
2684 !! test
2685 Resolving duplicate section names
2686 !! options
2687 title=[[Parser test script]]
2688 !! input
2689 == Foo bar ==
2690 == Foo bar ==
2691 !! result
2692 <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>
2693 <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>
2694
2695 !! end
2696
2697 !! article
2698 Template:sections
2699 !! text
2700 ===Section 1===
2701 ==Section 2==
2702 !! endarticle
2703
2704 !! test
2705 Template with sections, __NOTOC__
2706 !! options
2707 title=[[Parser test script]]
2708 !! input
2709 __NOTOC__
2710 ==Section 0==
2711 {{sections}}
2712 ==Section 4==
2713 !! result
2714 <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>
2715 <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>
2716 <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>
2717 <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>
2718
2719 !! end
2720
2721 !! test
2722 __NOEDITSECTION__ keyword
2723 !! input
2724 __NOEDITSECTION__
2725 ==Section 1==
2726 ==Section 2==
2727 !! result
2728 <a name="Section_1"></a><h2>Section 1</h2>
2729 <a name="Section_2"></a><h2>Section 2</h2>
2730
2731 !! end
2732
2733 !! test
2734 Link inside a section heading
2735 !! options
2736 title=[[Parser test script]]
2737 !! input
2738 ==Section with a [[Main Page|link]] in it==
2739 !! result
2740 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Section_with_a_link_in_it"></a><h2>Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</h2>
2741
2742 !! end
2743
2744
2745 !! test
2746 BUG 1219 URL next to image (good)
2747 !! input
2748 http://example.com [[Image:foobar.jpg]]
2749 !! result
2750 <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>
2751 </p>
2752 !!end
2753
2754 !! test
2755 BUG 1219 URL next to image (broken)
2756 !! input
2757 http://example.com[[Image:foobar.jpg]]
2758 !! result
2759 <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>
2760 </p>
2761 !!end
2762
2763 !! test
2764 Bug 1186 news: in the middle of text
2765 !! input
2766 http://en.wikinews.org/wiki/Wikinews:Workplace
2767 !! result
2768 <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>
2769 </p>
2770 !!end
2771
2772
2773 !! test
2774 Namespaced link must have a title
2775 !! input
2776 [[Project:]]
2777 !! result
2778 <p>[[Project:]]
2779 </p>
2780 !!end
2781
2782 !! test
2783 Namespaced link must have a title (bad fragment version)
2784 !! input
2785 [[Project:#fragment]]
2786 !! result
2787 <p>[[Project:#fragment]]
2788 </p>
2789 !!end
2790
2791
2792 !! test
2793 div with no attributes
2794 !! input
2795 <div>HTML rocks</div>
2796 !! result
2797 <div>HTML rocks</div>
2798
2799 !! end
2800
2801 !! test
2802 div with double-quoted attribute
2803 !! input
2804 <div id="rock">HTML rocks</div>
2805 !! result
2806 <div id="rock">HTML rocks</div>
2807
2808 !! end
2809
2810 !! test
2811 div with single-quoted attribute
2812 !! input
2813 <div id='rock'>HTML rocks</div>
2814 !! result
2815 <div id="rock">HTML rocks</div>
2816
2817 !! end
2818
2819 !! test
2820 div with unquoted attribute
2821 !! input
2822 <div id=rock>HTML rocks</div>
2823 !! result
2824 <div id="rock">HTML rocks</div>
2825
2826 !! end
2827
2828 !! test
2829 div with illegal double attributes
2830 !! input
2831 <div align="center" align="right">HTML rocks</div>
2832 !! result
2833 <div align="right">HTML rocks</div>
2834
2835 !!end
2836
2837 !! test
2838 HTML multiple attributes correction
2839 !! input
2840 <p class="error" class="awesome">Awesome!</p>
2841 !! result
2842 <p class="awesome">Awesome!</p>
2843
2844 !!end
2845
2846 !! test
2847 Table multiple attributes correction
2848 !! input
2849 {|
2850 !+ class="error" class="awesome"| status
2851 |}
2852 !! result
2853 <table>
2854 <tr>
2855 <th class="awesome"> status
2856 </th></tr></table>
2857
2858 !!end
2859
2860 !! test
2861 DIV IN UPPERCASE
2862 !! input
2863 <DIV ALIGN="center">HTML ROCKS</DIV>
2864 !! result
2865 <div align="center">HTML ROCKS</div>
2866
2867 !!end
2868
2869
2870 !! test
2871 text with amp in the middle of nowhere
2872 !! input
2873 Remember AT&T?
2874 !!result
2875 <p>Remember AT&amp;T?
2876 </p>
2877 !! end
2878
2879 !! test
2880 text with character entity: eacute
2881 !! input
2882 I always thought &eacute; was a cute letter.
2883 !! result
2884 <p>I always thought &eacute; was a cute letter.
2885 </p>
2886 !! end
2887
2888 !! test
2889 text with undefined character entity: xacute
2890 !! input
2891 I always thought &xacute; was a cute letter.
2892 !! result
2893 <p>I always thought &amp;xacute; was a cute letter.
2894 </p>
2895 !! end
2896
2897
2898 ###
2899 ### Media links
2900 ###
2901
2902 !! test
2903 Media link
2904 !! input
2905 [[Media:Foobar.jpg]]
2906 !! result
2907 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2908 </p>
2909 !! end
2910
2911 !! test
2912 Media link with text
2913 !! input
2914 [[Media:Foobar.jpg|A neat file to look at]]
2915 !! result
2916 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2917 </p>
2918 !! end
2919
2920 # FIXME: this is still bad HTML tag nesting
2921 !! test
2922 Media link with nasty text
2923 !! input
2924 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2925 !! result
2926 <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>
2927 </p>
2928 !! end
2929
2930 !! test
2931 Media link to nonexistent file (bug 1702)
2932 !! input
2933 [[Media:No such.jpg]]
2934 !! result
2935 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2936 </p>
2937 !! end
2938
2939 !! test
2940 Image link to nonexistent file (bug 1850 - good)
2941 !! input
2942 [[Image:No such.jpg]]
2943 !! result
2944 <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>
2945 </p>
2946 !! end
2947
2948 !! test
2949 :Image link to nonexistent file (bug 1850 - bad)
2950 !! input
2951 [[:Image:No such.jpg]]
2952 !! result
2953 <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>
2954 </p>
2955 !! end
2956
2957
2958
2959 !! test
2960 Character reference normalization in link text (bug 1938)
2961 !! input
2962 [[Main Page|this&that]]
2963 !! result
2964 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2965 </p>
2966 !!end
2967
2968 !! test
2969 Empty attribute crash test (bug 2067)
2970 !! input
2971 <font color="">foo</font>
2972 !! result
2973 <p><font color="">foo</font>
2974 </p>
2975 !! end
2976
2977 !! test
2978 Empty attribute crash test single-quotes (bug 2067)
2979 !! input
2980 <font color=''>foo</font>
2981 !! result
2982 <p><font color="">foo</font>
2983 </p>
2984 !! end
2985
2986 !! test
2987 Attribute test: equals, then nothing
2988 !! input
2989 <font color=>foo</font>
2990 !! result
2991 <p><font>foo</font>
2992 </p>
2993 !! end
2994
2995 !! test
2996 Attribute test: unquoted value
2997 !! input
2998 <font color=x>foo</font>
2999 !! result
3000 <p><font color="x">foo</font>
3001 </p>
3002 !! end
3003
3004 !! test
3005 Attribute test: unquoted but illegal value (hash)
3006 !! input
3007 <font color=#x>foo</font>
3008 !! result
3009 <p><font color="#x">foo</font>
3010 </p>
3011 !! end
3012
3013 !! test
3014 Attribute test: no value
3015 !! input
3016 <font color>foo</font>
3017 !! result
3018 <p><font color="color">foo</font>
3019 </p>
3020 !! end
3021
3022 !! test
3023 Bug 2095: link with three closing brackets
3024 !! input
3025 [[Main Page]]]
3026 !! result
3027 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
3028 </p>
3029 !! end
3030
3031 !! test
3032 Bug 2095: link with pipe and three closing brackets
3033 !! input
3034 [[Main Page|link]]]
3035 !! result
3036 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
3037 </p>
3038 !! end
3039
3040
3041 ###
3042 ### Safety
3043 ###
3044
3045 !! article
3046 Template:Dangerous attribute
3047 !! text
3048 " onmouseover="alert(document.cookie)
3049 !! endarticle
3050
3051 !! article
3052 Template:Dangerous style attribute
3053 !! text
3054 border-size: expression(alert(document.cookie))
3055 !! endarticle
3056
3057 !! article
3058 Template:Div style
3059 !! text
3060 <div style="float: right; {{{1}}}">Magic div</div>
3061 !! endarticle
3062
3063 !! test
3064 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
3065 !! input
3066 <div title="{{test}}"></div>
3067 !! result
3068 <div title="This is a test template"></div>
3069
3070 !! end
3071
3072 !! test
3073 Bug 2304: HTML attribute safety (dangerous template; 2309)
3074 !! input
3075 <div title="{{dangerous attribute}}"></div>
3076 !! result
3077 <div title=""></div>
3078
3079 !! end
3080
3081 !! test
3082 Bug 2304: HTML attribute safety (dangerous style template; 2309)
3083 !! input
3084 <div style="{{dangerous style attribute}}"></div>
3085 !! result
3086 <div></div>
3087
3088 !! end
3089
3090 !! test
3091 Bug 2304: HTML attribute safety (safe parameter; 2309)
3092 !! input
3093 {{div style|width: 200px}}
3094 !! result
3095 <div style="float: right; width: 200px">Magic div</div>
3096
3097 !! end
3098
3099 !! test
3100 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
3101 !! input
3102 {{div style|width: expression(alert(document.cookie))}}
3103 !! result
3104 <div>Magic div</div>
3105
3106 !! end
3107
3108 !! test
3109 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
3110 !! input
3111 {{div style|"><script>alert(document.cookie)</script>}}
3112 !! result
3113 <div>Magic div</div>
3114
3115 !! end
3116
3117 !! test
3118 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
3119 !! input
3120 {{div style|" ><script>alert(document.cookie)</script>}}
3121 !! result
3122 <div style="float: right; ">Magic div</div>
3123
3124 !! end
3125
3126 !! test
3127 Bug 2304: HTML attribute safety (link)
3128 !! input
3129 <div title="[[Main Page]]"></div>
3130 !! result
3131 <div title="&#91;&#91;Main Page]]"></div>
3132
3133 !! end
3134
3135 !! test
3136 Bug 2304: HTML attribute safety (italics)
3137 !! input
3138 <div title="''foobar''"></div>
3139 !! result
3140 <div title="&#39;&#39;foobar&#39;&#39;"></div>
3141
3142 !! end
3143
3144 !! test
3145 Bug 2304: HTML attribute safety (bold)
3146 !! input
3147 <div title="'''foobar'''"></div>
3148 !! result
3149 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
3150
3151 !! end
3152
3153
3154 !! test
3155 Bug 2304: HTML attribute safety (ISBN)
3156 !! input
3157 <div title="ISBN 1234567890"></div>
3158 !! result
3159 <div title="&#73;SBN 1234567890"></div>
3160
3161 !! end
3162
3163 !! test
3164 Bug 2304: HTML attribute safety (RFC)
3165 !! input
3166 <div title="RFC 1234"></div>
3167 !! result
3168 <div title="&#82;FC 1234"></div>
3169
3170 !! end
3171
3172 !! test
3173 Bug 2304: HTML attribute safety (PMID)
3174 !! input
3175 <div title="PMID 1234567890"></div>
3176 !! result
3177 <div title="&#80;MID 1234567890"></div>
3178
3179 !! end
3180
3181 !! test
3182 Bug 2304: HTML attribute safety (web link)
3183 !! input
3184 <div title="http://example.com/"></div>
3185 !! result
3186 <div title="http&#58;//example.com/"></div>
3187
3188 !! end
3189
3190 !! test
3191 Bug 2304: HTML attribute safety (named web link)
3192 !! input
3193 <div title="[http://example.com/ link]"></div>
3194 !! result
3195 <div title="&#91;http&#58;//example.com/ link]"></div>
3196
3197 !! end
3198
3199 !! test
3200 Bug 3244: HTML attribute safety (extension; safe)
3201 !! input
3202 <div style="<nowiki>background:blue</nowiki>"></div>
3203 !! result
3204 <div style="background:blue"></div>
3205
3206 !! end
3207
3208 !! test
3209 Bug 3244: HTML attribute safety (extension; unsafe)
3210 !! input
3211 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
3212 !! result
3213 <div></div>
3214
3215 !! end
3216
3217 !! test
3218 Math section safety when disabled
3219 !! input
3220 <math><script>alert(document.cookies);</script></math>
3221 !! result
3222 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
3223 </p>
3224 !! end
3225
3226 # More MSIE fun discovered by Tom Gilder
3227
3228 !! test
3229 MSIE CSS safety test: spurious slash
3230 !! input
3231 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
3232 !! result
3233 <div>evil</div>
3234
3235 !! end
3236
3237 !! test
3238 MSIE CSS safety test: hex code
3239 !! input
3240 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3241 !! result
3242 <div>evil</div>
3243
3244 !! end
3245
3246 !! test
3247 MSIE CSS safety test: comment in url
3248 !! input
3249 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3250 !! result
3251 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3252
3253 !! end
3254
3255 !! test
3256 MSIE CSS safety test: comment in expression
3257 !! input
3258 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3259 !! result
3260 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3261
3262 !! end
3263
3264
3265 !! test
3266 Table attribute legitimate extension
3267 !! input
3268 {|
3269 !+ style="<nowiki>color:blue</nowiki>"| status
3270 |}
3271 !! result
3272 <table>
3273 <tr>
3274 <th style="color:blue"> status
3275 </th></tr></table>
3276
3277 !!end
3278
3279 !! test
3280 Table attribute safety
3281 !! input
3282 {|
3283 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
3284 |}
3285 !! result
3286 <table>
3287 <tr>
3288 <th> status
3289 </th></tr></table>
3290
3291 !! end
3292
3293 ###
3294 ### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
3295 ###
3296 !! test
3297 Parser hook: empty input
3298 !! input
3299 <tag></tag>
3300 !! result
3301 <pre>
3302 string(0) ""
3303 array(0) {
3304 }
3305 </pre>
3306
3307 !! end
3308
3309 !! test
3310 Parser hook: empty input using terminated empty elements
3311 !! input
3312 <tag/>
3313 !! result
3314 <pre>
3315 NULL
3316 array(0) {
3317 }
3318 </pre>
3319
3320 !! end
3321
3322 !! test
3323 Parser hook: basic input
3324 !! input
3325 <tag>input</tag>
3326 !! result
3327 <pre>
3328 string(5) "input"
3329 array(0) {
3330 }
3331 </pre>
3332
3333 !! end
3334
3335
3336 !! test
3337 Parser hook: case insensetive
3338 !! input
3339 <TAG>input</TAG>
3340 !! result
3341 <pre>
3342 string(5) "input"
3343 array(0) {
3344 }
3345 </pre>
3346
3347 !! end
3348
3349
3350 !! test
3351 Parser hook: case insensetive, redux
3352 !! input
3353 <TaG>input</TAg>
3354 !! result
3355 <pre>
3356 string(5) "input"
3357 array(0) {
3358 }
3359 </pre>
3360
3361 !! end
3362
3363 !! test
3364 Parser hook: nested tags
3365 !! options
3366 noxml
3367 !! input
3368 <tag><tag></tag></tag>
3369 !! result
3370 <pre>
3371 string(5) "<tag>"
3372 array(0) {
3373 }
3374 </pre>&lt;/tag&gt;
3375
3376 !! end
3377
3378 !! test
3379 Parser hook: basic arguments
3380 !! input
3381 <tag width=200 height = "100" depth = '50' square></tag>
3382 !! result
3383 <pre>
3384 string(0) ""
3385 array(4) {
3386 ["width"]=>
3387 string(3) "200"
3388 ["height"]=>
3389 string(3) "100"
3390 ["depth"]=>
3391 string(2) "50"
3392 ["square"]=>
3393 string(6) "square"
3394 }
3395 </pre>
3396
3397 !! end
3398
3399 !! test
3400 Parser hook: empty input using terminated empty elements (bug 2374)
3401 !! input
3402 <tag foo=bar/>text
3403 !! result
3404 <pre>
3405 NULL
3406 array(1) {
3407 ["foo"]=>
3408 string(3) "bar"
3409 }
3410 </pre>text
3411
3412 !! end
3413
3414 # </tag> should be output literally since there is no matching tag that begins it
3415 !! test
3416 Parser hook: basic arguments using terminated empty elements (bug 2374)
3417 !! input
3418 <tag width=200 height = "100" depth = '50' square/>
3419 other stuff
3420 </tag>
3421 !! result
3422 <pre>
3423 NULL
3424 array(4) {
3425 ["width"]=>
3426 string(3) "200"
3427 ["height"]=>
3428 string(3) "100"
3429 ["depth"]=>
3430 string(2) "50"
3431 ["square"]=>
3432 string(6) "square"
3433 }
3434 </pre>
3435 <p>other stuff
3436 &lt;/tag&gt;
3437 </p>
3438 !! end
3439
3440
3441 # Nested template calls; this case was broken by Parser.php rev 1.506,
3442 # since reverted.
3443
3444 !! article
3445 Template:One-parameter
3446 !! text
3447 (My parameter is: {{{1}}})
3448 !! endarticle
3449
3450 !! article
3451 Template:Map-one-parameter
3452 !! text
3453 {{{{{1}}}|{{{2}}}}}
3454 !! endarticle
3455
3456 !! test
3457 Nested template calls
3458 !! input
3459 {{Map-one-parameter|One-parameter|param}}
3460 !! result
3461 <p>(My parameter is: param)
3462 </p>
3463 !! end
3464
3465
3466 ###
3467 ### Sanitizer
3468 ###
3469 !! test
3470 Sanitizer: Closing of open tags
3471 !! input
3472 <s></s><table></table>
3473 !! result
3474 <s></s><table></table>
3475
3476 !! end
3477
3478 !! test
3479 Sanitizer: Closing of open but not closed tags
3480 !! input
3481 <s>foo
3482 !! result
3483 <p><s>foo</s>
3484 </p>
3485 !! end
3486
3487 !! test
3488 Sanitizer: Closing of closed but not open tags
3489 !! input
3490 </s>
3491 !! result
3492 <p>&lt;/s&gt;
3493 </p>
3494 !! end
3495
3496 !! test
3497 Sanitizer: Closing of closed but not open table tags
3498 !! input
3499 Table not started</td></tr></table>
3500 !! result
3501 <p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
3502 </p>
3503 !! end
3504
3505 !! test
3506 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
3507 !! input
3508 <span id="æ: v">byte</span>[[#æ: v|backlink]]
3509 !! result
3510 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
3511 </p>
3512 !! end
3513
3514 !! test
3515 Sanitizer: Validating the contents of the id attribute (bug 4515)
3516 !! input
3517 <br id=9 />
3518 !! result
3519 Something, but defenetly not <br id="9" />...
3520 !! end
3521
3522 TODO:
3523 more images
3524 more tables
3525 math
3526 character entities
3527 and much more