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