that's what i get for committing tests at 1:30am
[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>'''not wiki'''
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>'''not wiki'''</noWIKI>
2438 !! result
2439 <NOwiki>'''not wiki'''</noWIKI>
2440 !! end
2441
2442 !! test
2443 pre-save transform: unclosed comment in <nowiki>
2444 !! options
2445 pst noxml
2446 !! input
2447 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
2448 !! result
2449 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
2450 !!end
2451
2452 !! article
2453 Template:dangerous
2454 !!text
2455 <span onmouseover="alert('crap')">Oh no</span>
2456 !!endarticle
2457
2458 !!test
2459 (confirming safety of fix for subst bug 1936)
2460 !! input
2461 {{Template:dangerous}}
2462 !! result
2463 <p><span>Oh no</span>
2464 </p>
2465 !! end
2466
2467 !! test
2468 pre-save transform: comment containing gallery (bug 5024)
2469 !! options
2470 pst
2471 !! input
2472 <!-- <gallery>data</gallery> -->
2473 !!result
2474 <!-- <gallery>data</gallery> -->
2475 !!end
2476
2477 !! test
2478 pre-save transform: comment containing extension
2479 !! options
2480 pst
2481 !! input
2482 <!-- <tag>data</tag> -->
2483 !!result
2484 <!-- <tag>data</tag> -->
2485 !!end
2486
2487 !! test
2488 pre-save transform: comment containing nowiki
2489 !! options
2490 pst
2491 !! input
2492 <!-- <nowiki>data</nowiki> -->
2493 !!result
2494 <!-- <nowiki>data</nowiki> -->
2495 !!end
2496
2497 !! test
2498 pre-save transform: comment containing math
2499 !! options
2500 pst
2501 !! input
2502 <!-- <math>data</math> -->
2503 !!result
2504 <!-- <math>data</math> -->
2505 !!end
2506
2507
2508 ###
2509 ### Message transform tests
2510 ###
2511 !! test
2512 message transform: magic variables
2513 !! options
2514 msg
2515 !! input
2516 {{SITENAME}}
2517 !! result
2518 MediaWiki
2519 !! end
2520
2521 !! test
2522 message transform: should not transform wiki markup
2523 !! options
2524 msg
2525 !! input
2526 ''test''
2527 !! result
2528 ''test''
2529 !! end
2530
2531 ###
2532 ### Images
2533 ###
2534 !! test
2535 Simple image
2536 !! input
2537 [[Image:foobar.jpg]]
2538 !! result
2539 <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>
2540 </p>
2541 !! end
2542
2543 !! test
2544 Right-aligned image
2545 !! input
2546 [[Image:foobar.jpg|right]]
2547 !! result
2548 <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>
2549
2550 !! end
2551
2552 !! test
2553 Image with caption
2554 !! input
2555 [[Image:foobar.jpg|right|Caption text]]
2556 !! result
2557 <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>
2558
2559 !! end
2560
2561 !! test
2562 Image with frame and link
2563 !! input
2564 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
2565 !! result
2566 <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>
2567
2568 !! end
2569
2570 !! test
2571 Link to image page- image page normally doesn't exists, hence edit link
2572 TODO: Add test with existing image page
2573 #<p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
2574 !! input
2575 [[:Image:test]]
2576 !! result
2577 <p><a href="/index.php?title=Image:Test&amp;action=edit" class="new" title="Image:Test">Image:test</a>
2578 </p>
2579 !! end
2580
2581 !! test
2582 Frameless image caption with a free URL
2583 !! input
2584 [[Image:foobar.jpg|http://example.com]]
2585 !! result
2586 <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>
2587 </p>
2588 !! end
2589
2590 !! test
2591 Thumbnail image caption with a free URL
2592 !! input
2593 [[Image:foobar.jpg|thumb|http://example.com]]
2594 !! result
2595 <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>
2596
2597 !! end
2598
2599 !! test
2600 BUG 1887: A ISBN with a thumbnail
2601 !! input
2602 [[Image:foobar.jpg|thumb|ISBN 12354]]
2603 !! result
2604 <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>
2605
2606 !! end
2607
2608 !! test
2609 BUG 1887: A RFC with a thumbnail
2610 !! input
2611 [[Image:foobar.jpg|thumb|This is RFC 12354]]
2612 !! result
2613 <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>
2614
2615 !! end
2616
2617 !! test
2618 BUG 1887: A mailto link with a thumbnail
2619 !! input
2620 [[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]]
2621 !! result
2622 <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>
2623
2624 !! end
2625
2626 !! test
2627 BUG 1887: A <math> with a thumbnail- we don't render math in the parsertests by default,
2628 so math is not stripped and turns up as escaped &lt;math&gt; tags.
2629 !! input
2630 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2631 !! result
2632 <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>
2633
2634 !! end
2635
2636 !! test
2637 BUG 1887, part 2: A <math> with a thumbnail- math enabled
2638 !! options
2639 math
2640 !! input
2641 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2642 !! result
2643 <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>
2644
2645 !! end
2646
2647 # Pending resolution to bug 368
2648 !! test
2649 BUG 648: Frameless image caption with a link
2650 !! input
2651 [[Image:foobar.jpg|text with a [[link]] in it]]
2652 !! result
2653 <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>
2654 </p>
2655 !! end
2656
2657 !! test
2658 BUG 648: Frameless image caption with a link (suffix)
2659 !! input
2660 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2661 !! result
2662 <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>
2663 </p>
2664 !! end
2665
2666 !! test
2667 BUG 648: Frameless image caption with an interwiki link
2668 !! input
2669 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2670 !! result
2671 <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>
2672 </p>
2673 !! end
2674
2675 !! test
2676 BUG 648: Frameless image caption with a piped interwiki link
2677 !! input
2678 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2679 !! result
2680 <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>
2681 </p>
2682 !! end
2683
2684 !! test
2685 Escape HTML special chars in image alt text
2686 !! input
2687 [[Image:foobar.jpg|& < > "]]
2688 !! result
2689 <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>
2690 </p>
2691 !! end
2692
2693 !! test
2694 BUG 499: Alt text should have &#1234;, not &amp;1234;
2695 !! input
2696 [[Image:foobar.jpg|&#9792;]]
2697 !! result
2698 <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>
2699 </p>
2700 !! end
2701
2702 !! test
2703 Broken image caption with link
2704 !! input
2705 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2706 !! result
2707 <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.
2708 </p>
2709 !! end
2710
2711 !! test
2712 Image caption containing another image
2713 !! input
2714 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2715 !! result
2716 <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>
2717
2718 !! end
2719
2720 !! test
2721 Image caption containing a newline
2722 !! input
2723 [[Image:Foobar.jpg|This
2724 *is some text]]
2725 !! result
2726 <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>
2727 </p>
2728 !!end
2729
2730
2731 !! test
2732 Bug 3090: External links other than http: in image captions
2733 !! input
2734 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2735 !! result
2736 <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>
2737
2738 !! end
2739
2740
2741 ###
2742 ### Subpages
2743 ###
2744 !! article
2745 Subpage test/subpage
2746 !! text
2747 foo
2748 !! endarticle
2749
2750 !! test
2751 Subpage link
2752 !! options
2753 subpage title=[[Subpage test]]
2754 !! input
2755 [[/subpage]]
2756 !! result
2757 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2758 </p>
2759 !! end
2760
2761 !! test
2762 Subpage noslash link
2763 !! options
2764 subpage title=[[Subpage test]]
2765 !!input
2766 [[/subpage/]]
2767 !! result
2768 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2769 </p>
2770 !! end
2771
2772 !! test
2773 Disabled subpages
2774 !! input
2775 [[/subpage]]
2776 !! result
2777 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2778 </p>
2779 !! end
2780
2781 !! test
2782 BUG 561: {{/Subpage}}
2783 !! options
2784 subpage title=[[Page]]
2785 !! input
2786 {{/Subpage}}
2787 !! result
2788 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2789 </p>
2790 !! end
2791
2792 ###
2793 ### Categories
2794 ###
2795 !! article
2796 Category:MediaWiki User's Guide
2797 !! text
2798 blah
2799 !! endarticle
2800
2801 !! test
2802 Link to category
2803 !! input
2804 [[:Category:MediaWiki User's Guide]]
2805 !! result
2806 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2807 </p>
2808 !! end
2809
2810 !! test
2811 Simple category
2812 !! options
2813 cat
2814 !! input
2815 [[Category:MediaWiki User's Guide]]
2816 !! result
2817 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2818 !! end
2819
2820 ###
2821 ### Inter-language links
2822 ###
2823 !! test
2824 Inter-language links
2825 !! options
2826 ill
2827 !! input
2828 [[es:Alimento]]
2829 [[fr:Nourriture]]
2830 [[zh:&#39135;&#21697;]]
2831 !! result
2832 es:Alimento fr:Nourriture zh:食品
2833 !! end
2834
2835 ###
2836 ### Sections
2837 ###
2838 !! test
2839 Basic section headings
2840 !! options
2841 title=[[Parser test script]]
2842 !! input
2843 == Headline 1 ==
2844 Some text
2845
2846 ==Headline 2==
2847 More
2848 ===Smaller headline===
2849 Blah blah
2850 !! result
2851 <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>
2852 <p>Some text
2853 </p>
2854 <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>
2855 <p>More
2856 </p>
2857 <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>
2858 <p>Blah blah
2859 </p>
2860 !! end
2861
2862 !! test
2863 Section headings with TOC
2864 !! options
2865 title=[[Parser test script]]
2866 !! input
2867 == Headline 1 ==
2868 === Subheadline 1 ===
2869 ===== Skipping a level =====
2870 ====== Skipping a level ======
2871
2872 == Headline 2 ==
2873 Some text
2874 ===Another headline===
2875 !! result
2876 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2877 <ul>
2878 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2879 <ul>
2880 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2881 <ul>
2882 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2883 <ul>
2884 <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>
2885 </ul>
2886 </li>
2887 </ul>
2888 </li>
2889 </ul>
2890 </li>
2891 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2892 <ul>
2893 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2894 </ul>
2895 </li>
2896 </ul>
2897 </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2898 <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>
2899 <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>
2900 <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>
2901 <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>
2902 <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>
2903 <p>Some text
2904 </p>
2905 <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>
2906
2907 !! end
2908
2909 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2910 !! test
2911 Handling of sections up to level 6 and beyond
2912 !! input
2913 = Level 1 Heading=
2914 == Level 2 Heading==
2915 === Level 3 Heading===
2916 ==== Level 4 Heading====
2917 ===== Level 5 Heading=====
2918 ====== Level 6 Heading======
2919 ======= Level 7 Heading=======
2920 ======== Level 8 Heading========
2921 ========= Level 9 Heading=========
2922 ========== Level 10 Heading==========
2923 !! result
2924 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2925 <ul>
2926 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2927 <ul>
2928 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2929 <ul>
2930 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2931 <ul>
2932 <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>
2933 <ul>
2934 <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>
2935 <ul>
2936 <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>
2937 <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>
2938 <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>
2939 <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>
2940 <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>
2941 </ul>
2942 </li>
2943 </ul>
2944 </li>
2945 </ul>
2946 </li>
2947 </ul>
2948 </li>
2949 </ul>
2950 </li>
2951 </ul>
2952 </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2953 <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>
2954 <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>
2955 <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>
2956 <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>
2957 <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>
2958 <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>
2959 <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>
2960 <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>
2961 <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>
2962 <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>
2963
2964 !! end
2965
2966 !! test
2967 Resolving duplicate section names
2968 !! options
2969 title=[[Parser test script]]
2970 !! input
2971 == Foo bar ==
2972 == Foo bar ==
2973 !! result
2974 <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>
2975 <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>
2976
2977 !! end
2978
2979 !! article
2980 Template:sections
2981 !! text
2982 ===Section 1===
2983 ==Section 2==
2984 !! endarticle
2985
2986 !! test
2987 Template with sections, __NOTOC__
2988 !! options
2989 title=[[Parser test script]]
2990 !! input
2991 __NOTOC__
2992 ==Section 0==
2993 {{sections}}
2994 ==Section 4==
2995 !! result
2996 <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>
2997 <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>
2998 <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>
2999 <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>
3000
3001 !! end
3002
3003 !! test
3004 __NOEDITSECTION__ keyword
3005 !! input
3006 __NOEDITSECTION__
3007 ==Section 1==
3008 ==Section 2==
3009 !! result
3010 <a name="Section_1"></a><h2>Section 1</h2>
3011 <a name="Section_2"></a><h2>Section 2</h2>
3012
3013 !! end
3014
3015 !! test
3016 Link inside a section heading
3017 !! options
3018 title=[[Parser test script]]
3019 !! input
3020 ==Section with a [[Main Page|link]] in it==
3021 !! result
3022 <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>
3023
3024 !! end
3025
3026
3027 !! test
3028 BUG 1219 URL next to image (good)
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 1219 URL next to image (broken)
3038 !! input
3039 http://example.com[[Image:foobar.jpg]]
3040 !! result
3041 <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>
3042 </p>
3043 !!end
3044
3045 !! test
3046 Bug 1186 news: in the middle of text
3047 !! input
3048 http://en.wikinews.org/wiki/Wikinews:Workplace
3049 !! result
3050 <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>
3051 </p>
3052 !!end
3053
3054
3055 !! test
3056 Namespaced link must have a title
3057 !! input
3058 [[Project:]]
3059 !! result
3060 <p>[[Project:]]
3061 </p>
3062 !!end
3063
3064 !! test
3065 Namespaced link must have a title (bad fragment version)
3066 !! input
3067 [[Project:#fragment]]
3068 !! result
3069 <p>[[Project:#fragment]]
3070 </p>
3071 !!end
3072
3073
3074 !! test
3075 div with no attributes
3076 !! input
3077 <div>HTML rocks</div>
3078 !! result
3079 <div>HTML rocks</div>
3080
3081 !! end
3082
3083 !! test
3084 div with double-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 single-quoted 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 unquoted attribute
3103 !! input
3104 <div id=rock>HTML rocks</div>
3105 !! result
3106 <div id="rock">HTML rocks</div>
3107
3108 !! end
3109
3110 !! test
3111 div with illegal double attributes
3112 !! input
3113 <div align="center" align="right">HTML rocks</div>
3114 !! result
3115 <div align="right">HTML rocks</div>
3116
3117 !!end
3118
3119 !! test
3120 HTML multiple attributes correction
3121 !! input
3122 <p class="error" class="awesome">Awesome!</p>
3123 !! result
3124 <p class="awesome">Awesome!</p>
3125
3126 !!end
3127
3128 !! test
3129 Table multiple attributes correction
3130 !! input
3131 {|
3132 !+ class="error" class="awesome"| status
3133 |}
3134 !! result
3135 <table>
3136 <tr>
3137 <th class="awesome"> status
3138 </th></tr></table>
3139
3140 !!end
3141
3142 !! test
3143 DIV IN UPPERCASE
3144 !! input
3145 <DIV ALIGN="center">HTML ROCKS</DIV>
3146 !! result
3147 <div align="center">HTML ROCKS</div>
3148
3149 !!end
3150
3151
3152 !! test
3153 text with amp in the middle of nowhere
3154 !! input
3155 Remember AT&T?
3156 !!result
3157 <p>Remember AT&amp;T?
3158 </p>
3159 !! end
3160
3161 !! test
3162 text with character entity: eacute
3163 !! input
3164 I always thought &eacute; was a cute letter.
3165 !! result
3166 <p>I always thought &eacute; was a cute letter.
3167 </p>
3168 !! end
3169
3170 !! test
3171 text with undefined character entity: xacute
3172 !! input
3173 I always thought &xacute; was a cute letter.
3174 !! result
3175 <p>I always thought &amp;xacute; was a cute letter.
3176 </p>
3177 !! end
3178
3179
3180 ###
3181 ### Media links
3182 ###
3183
3184 !! test
3185 Media link
3186 !! input
3187 [[Media:Foobar.jpg]]
3188 !! result
3189 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
3190 </p>
3191 !! end
3192
3193 !! test
3194 Media link with text
3195 !! input
3196 [[Media:Foobar.jpg|A neat file to look at]]
3197 !! result
3198 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
3199 </p>
3200 !! end
3201
3202 # FIXME: this is still bad HTML tag nesting
3203 !! test
3204 Media link with nasty text
3205 fixme: doBlockLevels won't wrap this in a paragraph because it contains a div
3206 !! input
3207 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
3208 !! result
3209 <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>
3210
3211 !! end
3212
3213 !! test
3214 Media link to nonexistent file (bug 1702)
3215 !! input
3216 [[Media:No such.jpg]]
3217 !! result
3218 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
3219 </p>
3220 !! end
3221
3222 !! test
3223 Image link to nonexistent file (bug 1850 - good)
3224 !! input
3225 [[Image:No such.jpg]]
3226 !! result
3227 <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>
3228 </p>
3229 !! end
3230
3231 !! test
3232 :Image link to nonexistent file (bug 1850 - bad)
3233 !! input
3234 [[:Image:No such.jpg]]
3235 !! result
3236 <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>
3237 </p>
3238 !! end
3239
3240
3241
3242 !! test
3243 Character reference normalization in link text (bug 1938)
3244 !! input
3245 [[Main Page|this&that]]
3246 !! result
3247 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
3248 </p>
3249 !!end
3250
3251 !! test
3252 Empty attribute crash test (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 Empty attribute crash test single-quotes (bug 2067)
3262 !! input
3263 <font color=''>foo</font>
3264 !! result
3265 <p><font color="">foo</font>
3266 </p>
3267 !! end
3268
3269 !! test
3270 Attribute test: equals, then nothing
3271 !! input
3272 <font color=>foo</font>
3273 !! result
3274 <p><font>foo</font>
3275 </p>
3276 !! end
3277
3278 !! test
3279 Attribute test: unquoted value
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: unquoted but illegal value (hash)
3289 !! input
3290 <font color=#x>foo</font>
3291 !! result
3292 <p><font color="#x">foo</font>
3293 </p>
3294 !! end
3295
3296 !! test
3297 Attribute test: no value
3298 !! input
3299 <font color>foo</font>
3300 !! result
3301 <p><font color="color">foo</font>
3302 </p>
3303 !! end
3304
3305 !! test
3306 Bug 2095: link with three closing brackets
3307 !! input
3308 [[Main Page]]]
3309 !! result
3310 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
3311 </p>
3312 !! end
3313
3314 !! test
3315 Bug 2095: link with pipe and three closing brackets
3316 !! input
3317 [[Main Page|link]]]
3318 !! result
3319 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
3320 </p>
3321 !! end
3322
3323 !! test
3324 Bug 2095: link with pipe and three closing brackets, version 2
3325 !! input
3326 [[Main Page|[http://example.com/]]]
3327 !! result
3328 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
3329 </p>
3330 !! end
3331
3332
3333 ###
3334 ### Safety
3335 ###
3336
3337 !! article
3338 Template:Dangerous attribute
3339 !! text
3340 " onmouseover="alert(document.cookie)
3341 !! endarticle
3342
3343 !! article
3344 Template:Dangerous style attribute
3345 !! text
3346 border-size: expression(alert(document.cookie))
3347 !! endarticle
3348
3349 !! article
3350 Template:Div style
3351 !! text
3352 <div style="float: right; {{{1}}}">Magic div</div>
3353 !! endarticle
3354
3355 !! test
3356 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
3357 !! input
3358 <div title="{{test}}"></div>
3359 !! result
3360 <div title="This is a test template"></div>
3361
3362 !! end
3363
3364 !! test
3365 Bug 2304: HTML attribute safety (dangerous template; 2309)
3366 !! input
3367 <div title="{{dangerous attribute}}"></div>
3368 !! result
3369 <div title=""></div>
3370
3371 !! end
3372
3373 !! test
3374 Bug 2304: HTML attribute safety (dangerous style template; 2309)
3375 !! input
3376 <div style="{{dangerous style attribute}}"></div>
3377 !! result
3378 <div></div>
3379
3380 !! end
3381
3382 !! test
3383 Bug 2304: HTML attribute safety (safe parameter; 2309)
3384 !! input
3385 {{div style|width: 200px}}
3386 !! result
3387 <div style="float: right; width: 200px">Magic div</div>
3388
3389 !! end
3390
3391 !! test
3392 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
3393 !! input
3394 {{div style|width: expression(alert(document.cookie))}}
3395 !! result
3396 <div>Magic div</div>
3397
3398 !! end
3399
3400 !! test
3401 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
3402 !! input
3403 {{div style|"><script>alert(document.cookie)</script>}}
3404 !! result
3405 <div>Magic div</div>
3406
3407 !! end
3408
3409 !! test
3410 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
3411 !! input
3412 {{div style|" ><script>alert(document.cookie)</script>}}
3413 !! result
3414 <div style="float: right; ">Magic div</div>
3415
3416 !! end
3417
3418 !! test
3419 Bug 2304: HTML attribute safety (link)
3420 !! input
3421 <div title="[[Main Page]]"></div>
3422 !! result
3423 <div title="&#91;&#91;Main Page]]"></div>
3424
3425 !! end
3426
3427 !! test
3428 Bug 2304: HTML attribute safety (italics)
3429 !! input
3430 <div title="''foobar''"></div>
3431 !! result
3432 <div title="&#39;&#39;foobar&#39;&#39;"></div>
3433
3434 !! end
3435
3436 !! test
3437 Bug 2304: HTML attribute safety (bold)
3438 !! input
3439 <div title="'''foobar'''"></div>
3440 !! result
3441 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
3442
3443 !! end
3444
3445
3446 !! test
3447 Bug 2304: HTML attribute safety (ISBN)
3448 !! input
3449 <div title="ISBN 1234567890"></div>
3450 !! result
3451 <div title="&#73;SBN 1234567890"></div>
3452
3453 !! end
3454
3455 !! test
3456 Bug 2304: HTML attribute safety (RFC)
3457 !! input
3458 <div title="RFC 1234"></div>
3459 !! result
3460 <div title="&#82;FC 1234"></div>
3461
3462 !! end
3463
3464 !! test
3465 Bug 2304: HTML attribute safety (PMID)
3466 !! input
3467 <div title="PMID 1234567890"></div>
3468 !! result
3469 <div title="&#80;MID 1234567890"></div>
3470
3471 !! end
3472
3473 !! test
3474 Bug 2304: HTML attribute safety (web link)
3475 !! input
3476 <div title="http://example.com/"></div>
3477 !! result
3478 <div title="http&#58;//example.com/"></div>
3479
3480 !! end
3481
3482 !! test
3483 Bug 2304: HTML attribute safety (named web link)
3484 !! input
3485 <div title="[http://example.com/ link]"></div>
3486 !! result
3487 <div title="&#91;http&#58;//example.com/ link]"></div>
3488
3489 !! end
3490
3491 !! test
3492 Bug 3244: HTML attribute safety (extension; safe)
3493 !! input
3494 <div style="<nowiki>background:blue</nowiki>"></div>
3495 !! result
3496 <div style="background:blue"></div>
3497
3498 !! end
3499
3500 !! test
3501 Bug 3244: HTML attribute safety (extension; unsafe)
3502 !! input
3503 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
3504 !! result
3505 <div></div>
3506
3507 !! end
3508
3509 !! test
3510 Math section safety when disabled
3511 !! input
3512 <math><script>alert(document.cookies);</script></math>
3513 !! result
3514 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
3515 </p>
3516 !! end
3517
3518 # More MSIE fun discovered by Tom Gilder
3519
3520 !! test
3521 MSIE CSS safety test: spurious slash
3522 !! input
3523 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
3524 !! result
3525 <div>evil</div>
3526
3527 !! end
3528
3529 !! test
3530 MSIE CSS safety test: hex code
3531 !! input
3532 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3533 !! result
3534 <div>evil</div>
3535
3536 !! end
3537
3538 !! test
3539 MSIE CSS safety test: comment in url
3540 !! input
3541 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3542 !! result
3543 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3544
3545 !! end
3546
3547 !! test
3548 MSIE CSS safety test: comment in expression
3549 !! input
3550 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3551 !! result
3552 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3553
3554 !! end
3555
3556
3557 !! test
3558 Table attribute legitimate extension
3559 !! input
3560 {|
3561 !+ style="<nowiki>color:blue</nowiki>"| status
3562 |}
3563 !! result
3564 <table>
3565 <tr>
3566 <th style="color:blue"> status
3567 </th></tr></table>
3568
3569 !!end
3570
3571 !! test
3572 Table attribute safety
3573 !! input
3574 {|
3575 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
3576 |}
3577 !! result
3578 <table>
3579 <tr>
3580 <th> status
3581 </th></tr></table>
3582
3583 !! end
3584
3585 ###
3586 ### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
3587 ###
3588 !! test
3589 Parser hook: empty input
3590 !! input
3591 <tag></tag>
3592 !! result
3593 <pre>
3594 string(0) ""
3595 array(0) {
3596 }
3597 </pre>
3598
3599 !! end
3600
3601 !! test
3602 Parser hook: empty input using terminated empty elements
3603 !! input
3604 <tag/>
3605 !! result
3606 <pre>
3607 NULL
3608 array(0) {
3609 }
3610 </pre>
3611
3612 !! end
3613
3614 !! test
3615 Parser hook: empty input using terminated empty elements (space before)
3616 !! input
3617 <tag />
3618 !! result
3619 <pre>
3620 NULL
3621 array(0) {
3622 }
3623 </pre>
3624
3625 !! end
3626
3627 !! test
3628 Parser hook: basic input
3629 !! input
3630 <tag>input</tag>
3631 !! result
3632 <pre>
3633 string(5) "input"
3634 array(0) {
3635 }
3636 </pre>
3637
3638 !! end
3639
3640
3641 !! test
3642 Parser hook: case insensetive
3643 !! input
3644 <TAG>input</TAG>
3645 !! result
3646 <pre>
3647 string(5) "input"
3648 array(0) {
3649 }
3650 </pre>
3651
3652 !! end
3653
3654
3655 !! test
3656 Parser hook: case insensetive, redux
3657 !! input
3658 <TaG>input</TAg>
3659 !! result
3660 <pre>
3661 string(5) "input"
3662 array(0) {
3663 }
3664 </pre>
3665
3666 !! end
3667
3668 !! test
3669 Parser hook: nested tags
3670 !! options
3671 noxml
3672 !! input
3673 <tag><tag></tag></tag>
3674 !! result
3675 <pre>
3676 string(5) "<tag>"
3677 array(0) {
3678 }
3679 </pre>&lt;/tag&gt;
3680
3681 !! end
3682
3683 !! test
3684 Parser hook: basic arguments
3685 !! input
3686 <tag width=200 height = "100" depth = '50' square></tag>
3687 !! result
3688 <pre>
3689 string(0) ""
3690 array(4) {
3691 ["width"]=>
3692 string(3) "200"
3693 ["height"]=>
3694 string(3) "100"
3695 ["depth"]=>
3696 string(2) "50"
3697 ["square"]=>
3698 string(6) "square"
3699 }
3700 </pre>
3701
3702 !! end
3703
3704 !! test
3705 Parser hook: argument containing a forward slash (bug 5344)
3706 !! input
3707 <tag filename='/tmp/bla'></tag>
3708 !! result
3709 <pre>
3710 string(0) ""
3711 array(1) {
3712 ["filename"]=>
3713 string(8) "/tmp/bla"
3714 }
3715 </pre>
3716
3717 !! end
3718
3719 !! test
3720 Parser hook: empty input using terminated empty elements (bug 2374)
3721 !! input
3722 <tag foo=bar/>text
3723 !! result
3724 <pre>
3725 NULL
3726 array(1) {
3727 ["foo"]=>
3728 string(3) "bar"
3729 }
3730 </pre>text
3731
3732 !! end
3733
3734 # </tag> should be output literally since there is no matching tag that begins it
3735 !! test
3736 Parser hook: basic arguments using terminated empty elements (bug 2374)
3737 !! input
3738 <tag width=200 height = "100" depth = '50' square/>
3739 other stuff
3740 </tag>
3741 !! result
3742 <pre>
3743 NULL
3744 array(4) {
3745 ["width"]=>
3746 string(3) "200"
3747 ["height"]=>
3748 string(3) "100"
3749 ["depth"]=>
3750 string(2) "50"
3751 ["square"]=>
3752 string(6) "square"
3753 }
3754 </pre>
3755 <p>other stuff
3756 &lt;/tag&gt;
3757 </p>
3758 !! end
3759
3760 ###
3761 ### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
3762 ###
3763
3764 !! test
3765 Parser hook: static parser hook not inside a comment
3766 !! input
3767 <statictag>hello, world</statictag>
3768 <statictag action=flush/>
3769 !! result
3770 <p>hello, world
3771 </p>
3772 !! end
3773
3774
3775 !! test
3776 Parser hook: static parser hook inside a comment
3777 !! input
3778 <!-- <statictag>hello, world</statictag> -->
3779 <statictag action=flush/>
3780 !! result
3781 <p><br />
3782 </p>
3783 !! end
3784
3785 # Nested template calls; this case was broken by Parser.php rev 1.506,
3786 # since reverted.
3787
3788 !! article
3789 Template:One-parameter
3790 !! text
3791 (My parameter is: {{{1}}})
3792 !! endarticle
3793
3794 !! article
3795 Template:Map-one-parameter
3796 !! text
3797 {{{{{1}}}|{{{2}}}}}
3798 !! endarticle
3799
3800 !! test
3801 Nested template calls
3802 !! input
3803 {{Map-one-parameter|One-parameter|param}}
3804 !! result
3805 <p>(My parameter is: param)
3806 </p>
3807 !! end
3808
3809
3810 ###
3811 ### Sanitizer
3812 ###
3813 !! test
3814 Sanitizer: Closing of open tags
3815 !! input
3816 <s></s><table></table>
3817 !! result
3818 <s></s><table></table>
3819
3820 !! end
3821
3822 !! test
3823 Sanitizer: Closing of open but not closed tags
3824 !! input
3825 <s>foo
3826 !! result
3827 <p><s>foo</s>
3828 </p>
3829 !! end
3830
3831 !! test
3832 Sanitizer: Closing of closed but not open tags
3833 !! input
3834 </s>
3835 !! result
3836 <p>&lt;/s&gt;
3837 </p>
3838 !! end
3839
3840 !! test
3841 Sanitizer: Closing of closed but not open table tags
3842 !! input
3843 Table not started</td></tr></table>
3844 !! result
3845 <p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
3846 </p>
3847 !! end
3848
3849 !! test
3850 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
3851 !! input
3852 <span id="æ: v">byte</span>[[#æ: v|backlink]]
3853 !! result
3854 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
3855 </p>
3856 !! end
3857
3858 !! test
3859 Sanitizer: Validating the contents of the id attribute (bug 4515)
3860 !! options
3861 disabled
3862 !! input
3863 <br id=9 />
3864 !! result
3865 Something, but defenetly not <br id="9" />...
3866 !! end
3867
3868 !! test
3869 Language converter: output gets cut off unexpectedly (bug 5757)
3870 !! options
3871 language=zh
3872 !! input
3873 this bit is safe: }-
3874
3875 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
3876
3877 then we get cut off here: }-
3878
3879 all additional text is vanished
3880 !! result
3881 <p>this bit is safe: }-
3882 </p><p>but if we add a conversion instance: xxx
3883 </p><p>then we get cut off here: }-
3884 </p><p>all additional text is vanished
3885 </p>
3886 !! end
3887
3888 !! test
3889 Self closed html pairs (bug 5487)
3890 !! options
3891 !! input
3892 <center><font id="bug" />Centered text</center>
3893 <div><font id="bug2" />In div text</div>
3894 !! result
3895 <div class="center">&lt;font id="bug" /&gt;Centered text</div>
3896 <div>&lt;font id="bug2" /&gt;In div text</div>
3897
3898 !! end
3899
3900 #
3901 #
3902 #
3903
3904 !! test
3905 HTML bullet list, closed tags (bug 5497)
3906 !! input
3907 <ul>
3908 <li>One</li>
3909 <li>Two</li>
3910 </ul>
3911 !! result
3912 <ul>
3913 <li>One</li>
3914 <li>Two</li>
3915 </ul>
3916
3917 !! end
3918
3919 !! test
3920 HTML bullet list, unclosed tags (bug 5497)
3921 !! input
3922 <ul>
3923 <li>One
3924 <li>Two
3925 </ul>
3926 !! result
3927 <ul>
3928 <li>One
3929 </li><li>Two
3930 </li></ul>
3931
3932 !! end
3933
3934 !! test
3935 HTML ordered list, closed tags (bug 5497)
3936 !! input
3937 <ol>
3938 <li>One</li>
3939 <li>Two</li>
3940 </ol>
3941 !! result
3942 <ol>
3943 <li>One</li>
3944 <li>Two</li>
3945 </ol>
3946
3947 !! end
3948
3949 !! test
3950 HTML ordered list, unclosed tags (bug 5497)
3951 !! input
3952 <ol>
3953 <li>One
3954 <li>Two
3955 </ol>
3956 !! result
3957 <ol>
3958 <li>One
3959 </li><li>Two
3960 </li></ol>
3961
3962 !! end
3963
3964 !! test
3965 HTML nested bullet list, closed tags (bug 5497)
3966 !! input
3967 <ul>
3968 <li>One</li>
3969 <li>Two:
3970 <ul>
3971 <li>Sub-one</li>
3972 <li>Sub-two</li>
3973 </ul>
3974 </li>
3975 </ul>
3976 !! result
3977 <ul>
3978 <li>One</li>
3979 <li>Two:
3980 <ul>
3981 <li>Sub-one</li>
3982 <li>Sub-two</li>
3983 </ul>
3984 </li>
3985 </ul>
3986
3987 !! end
3988
3989 !! test
3990 HTML nested bullet list, open tags (bug 5497)
3991 !! input
3992 <ul>
3993 <li>One
3994 <li>Two:
3995 <ul>
3996 <li>Sub-one
3997 <li>Sub-two
3998 </ul>
3999 </li>
4000 </ul>
4001 !! result
4002 <ul>
4003 <li>One
4004 </li><li>Two:
4005 <ul>
4006 <li>Sub-one
4007 </li><li>Sub-two
4008 </li></ul>
4009 </li></ul>
4010
4011 !! end
4012
4013 !! test
4014 HTML nested ordered list, closed tags (bug 5497)
4015 !! input
4016 <ol>
4017 <li>One</li>
4018 <li>Two:
4019 <ol>
4020 <li>Sub-one</li>
4021 <li>Sub-two</li>
4022 </ol>
4023 </li>
4024 </ol>
4025 !! result
4026 <ol>
4027 <li>One</li>
4028 <li>Two:
4029 <ol>
4030 <li>Sub-one</li>
4031 <li>Sub-two</li>
4032 </ol>
4033 </li>
4034 </ol>
4035
4036 !! end
4037
4038 !! test
4039 HTML nested ordered list, open tags (bug 5497)
4040 !! input
4041 <ol>
4042 <li>One
4043 <li>Two:
4044 <ol>
4045 <li>Sub-one
4046 <li>Sub-two
4047 </ol>
4048 </li>
4049 </ol>
4050 !! result
4051 <ol>
4052 <li>One
4053 </li><li>Two:
4054 <ol>
4055 <li>Sub-one
4056 </li><li>Sub-two
4057 </li></ol>
4058 </li></ol>
4059
4060 !! end
4061
4062 !! test
4063 HTML ordered list item with parameters oddity
4064 !! input
4065 <ol><li id="fragment">One</li></ol>
4066 !! result
4067 <ol><li id="fragment">One</li></ol>
4068
4069 !! end
4070
4071 !!test
4072 bug 5918: autonumbering
4073 !! input
4074 [http://first/] [http://second] [ftp://ftp]
4075
4076 ftp://inlineftp
4077
4078 [mailto:enclosed@mail.tld With target]
4079
4080 [mailto:enclosed@mail.tld]
4081
4082 mailto:inline@mail.tld
4083 !! result
4084 <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>
4085 </p><p><a href="ftp://inlineftp" class='external free' title="ftp://inlineftp" rel="nofollow">ftp://inlineftp</a>
4086 </p><p><a href="mailto:enclosed@mail.tld" class='external text' title="mailto:enclosed@mail.tld" rel="nofollow">With target</a>
4087 </p><p><a href="mailto:enclosed@mail.tld" class='external autonumber' title="mailto:enclosed@mail.tld" rel="nofollow">[4]</a>
4088 </p><p><a href="mailto:inline@mail.tld" class='external free' title="mailto:inline@mail.tld" rel="nofollow">mailto:inline@mail.tld</a>
4089 </p>
4090 !! end
4091
4092
4093 #
4094 # Security and HTML correctness
4095 # From Nick Jenkins' fuzz testing
4096 #
4097
4098 !! test
4099 Fuzz testing: Parser13
4100 !! input
4101 {|
4102 | http://a|
4103 !! result
4104 <table>
4105 <tr>
4106 <td>
4107 </td>
4108 </tr>
4109 </table>
4110
4111 !! end
4112
4113 !! test
4114 Fuzz testing: Parser14
4115 !! input
4116 == onmouseover= ==
4117 http://__TOC__
4118 !! result
4119 <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>
4120 http://<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
4121 <ul>
4122 <li class='toclevel-1'><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
4123 </ul>
4124 </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
4125
4126 !! end
4127
4128 !! test
4129 Fuzz testing: Parser14-table
4130 !! input
4131 ==a==
4132 {| STYLE=__TOC__
4133 !! result
4134 <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>
4135 <table style="&#95;_TOC&#95;_">
4136 <tr><td></td></tr>
4137 </table>
4138
4139 !! end
4140
4141 # Known to produce bogus xml (extra </td>)
4142 !! test
4143 Fuzz testing: Parser16
4144 !! options
4145 noxml
4146 !! input
4147 {|
4148 !https://||||||
4149 !! result
4150 <table>
4151 <tr>
4152 <th>https://</th><th></th><th></th><th>
4153 </td>
4154 </tr>
4155 </table>
4156
4157 !! end
4158
4159 !! test
4160 Fuzz testing: Parser21
4161 !! input
4162 {|
4163 ! irc://{{ftp://a" onmouseover="alert('hello world');"
4164 |
4165 !! result
4166 <table>
4167 <tr>
4168 <th> <a href="irc://{{ftp://a" class='external free' title="irc://{{ftp://a" rel="nofollow">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
4169 </th><td>
4170 </td>
4171 </tr>
4172 </table>
4173
4174 !! end
4175
4176 !! test
4177 Fuzz testing: Parser22
4178 !! input
4179 http://===r:::https://b
4180
4181 {|
4182 !!result
4183 <p><a href="http://===r:::https://b" class='external free' title="http://===r:::https://b" rel="nofollow">http://===r:::https://b</a>
4184 </p>
4185 <table>
4186 <tr><td></td></tr>
4187 </table>
4188
4189 !! end
4190
4191 # Known to produce bad XML for now
4192 !! test
4193 Fuzz testing: Parser24
4194 !! options
4195 noxml
4196 !! input
4197 {|
4198 {{{|
4199 <u CLASS=
4200 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
4201 <br style="onmouseover='alert(document.cookie);' " />
4202
4203 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
4204 |
4205 !! result
4206 <table>
4207
4208 <u class="&#124;">} &gt;
4209 <br style="onmouseover='alert(document.cookie);' " />
4210
4211 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
4212 <tr>
4213 <td></u>
4214 </td>
4215 </tr>
4216 </table>
4217
4218 !! end
4219
4220 # Known to produce bad XML for now
4221 !!test
4222 Fuzz testing: Parser25 (bug 6055)
4223 !! options
4224 noxml
4225 !! input
4226 {{{
4227 |
4228 <LI CLASS=||
4229 >
4230 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
4231 !! result
4232 <li class="&#124;&#124;">
4233 blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
4234
4235 !! end
4236
4237 !!test
4238 Fuzz testing: URL adjacent extension (with space, clean)
4239 !! options
4240 !! input
4241 http://example.com <nowiki>junk</nowiki>
4242 !! result
4243 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a> junk
4244 </p>
4245 !!end
4246
4247 !!test
4248 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
4249 !! options
4250 !! input
4251 http://example.com<nowiki>junk</nowiki>
4252 !! result
4253 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>junk
4254 </p>
4255 !!end
4256
4257 !!test
4258 Fuzz testing: URL adjacent extension (no space, dirty; pre)
4259 !! options
4260 !! input
4261 http://example.com<pre>junk</pre>
4262 !! result
4263 <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a><pre>junk</pre>
4264
4265 !!end
4266
4267 #
4268 #
4269 #
4270
4271 TODO:
4272 more images
4273 more tables
4274 math
4275 character entities
4276 and much more