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