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