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