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