* Consistant style in buildSidebar()
[mediawiki.git] / maintenance / parserTests.txt
blobdbb2b718d533a9c4d86d2e657c31979a07dda45c
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
5 # The syntax should be fairly self-explanatory.
7 # Currently supported test options:
8 #       One of the following three:
10 #       (default)       generate HTML output
11 #       pst             apply pre-save transform
12 #       msg             apply message transform
14 #       Plus any combination of these:
16 #       cat             add category links
17 #       ill             add inter-language links
18 #       subpage         enable subpages (disabled by default)
19 #       title=[[XXX]]   run test using article title XXX
20 #       disabled        do not run test
22 # For testing purposes, temporary articles can created:
23 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
24 # where '/' denotes a newline.
26 # This is the standard article assumed to exist.
27 !! article
28 Main Page
29 !! text
30 blah blah
31 !! endarticle
33 ###
34 ### Basic tests
35 ###
36 !! test
37 Blank input
38 !! input
39 !! result
40 !! end
43 !! test
44 Simple paragraph
45 !! input
46 This is a simple paragraph.
47 !! result
48 <p>This is a simple paragraph.
49 </p>
50 !! end
52 !! test
53 Simple list
54 !! input
55 * Item 1
56 * Item 2
57 !! result
58 <ul><li> Item 1
59 </li><li> Item 2
60 </li></ul>
62 !! end
64 !! test
65 Italics and bold
66 !! input
67 * plain
68 * plain''italic''plain
69 * plain''italic''plain''italic''plain
70 * plain'''bold'''plain
71 * plain'''bold'''plain'''bold'''plain
72 * plain''italic''plain'''bold'''plain
73 * plain'''bold'''plain''italic''plain
74 * plain''italic'''bold-italic'''italic''plain
75 * plain'''bold''bold-italic''bold'''plain
76 * plain'''''bold-italic'''italic''plain
77 * plain'''''bold-italic''bold'''plain
78 * plain''italic'''bold-italic'''''plain
79 * plain'''bold''bold-italic'''''plain
80 * plain l'''italic''plain
81 !! result
82 <ul><li> plain
83 </li><li> plain<i>italic</i>plain
84 </li><li> plain<i>italic</i>plain<i>italic</i>plain
85 </li><li> plain<b>bold</b>plain
86 </li><li> plain<b>bold</b>plain<b>bold</b>plain
87 </li><li> plain<i>italic</i>plain<b>bold</b>plain
88 </li><li> plain<b>bold</b>plain<i>italic</i>plain
89 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
90 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
91 </li><li> plain<i><b>bold-italic</b>italic</i>plain
92 </li><li> plain<b><i>bold-italic</i>bold</b>plain
93 </li><li> plain<i>italic<b>bold-italic</b></i>plain
94 </li><li> plain<b>bold<i>bold-italic</i></b>plain
95 </li><li> plain l'<i>italic</i>plain
96 </li></ul>
98 !! end
101 ### <nowiki> test cases
104 !! test
105 <nowiki> unordered list
106 !! input
107 <nowiki>* This is not an unordered list item.</nowiki>
108 !! result
109 <p>* This is not an unordered list item.
110 </p>
111 !! end
113 !! test
114 <nowiki> spacing
115 !! input
116 <nowiki>Lorem ipsum dolor
118 sed abit.
119   sed nullum.
121 :and a colon
122 </nowiki>
123 !! result
124 <p>Lorem ipsum dolor
126 sed abit.
127   sed nullum.
129 :and a colon
131 </p>
132 !! end
134 !! test
135 nowiki 3
136 !! input
137 :There is not nowiki.
138 :There is <nowiki>nowiki</nowiki>.
140 #There is not nowiki.
141 #There is <nowiki>nowiki</nowiki>.
143 *There is not nowiki.
144 *There is <nowiki>nowiki</nowiki>.
145 !! result
146 <dl><dd>There is not nowiki.
147 </dd><dd>There is nowiki.
148 </dd></dl>
149 <ol><li>There is not nowiki.
150 </li><li>There is nowiki.
151 </li></ol>
152 <ul><li>There is not nowiki.
153 </li><li>There is nowiki.
154 </li></ul>
156 !! end
159 ### Comments
161 !! test
162 Comment test 1
163 !! input
164 <!-- comment 1 --> asdf
165 <!-- comment 2 -->
166 !! result
167 <pre>asdf
168 </pre>
170 !! end
172 !! test
173 Comment test 2
174 !! input
175 asdf
176 <!-- comment 1 -->
178 !! result
179 <p>asdf
181 </p>
182 !! end
184 !! test
185 Comment test 3
186 !! input
187 asdf
188 <!-- comment 1 -->
189 <!-- comment 2 -->
191 !! result
192 <p>asdf
194 </p>
195 !! end
197 !! test
198 Comment test 4
199 !! input
200 asdf<!-- comment 1 -->jkl
201 !! result
202 <p>asdfjkl
203 </p>
204 !! end
206 !! test
207 Comment spacing
208 !! input
210  <!-- foo --> b <!-- bar -->
212 !! result
213 <p>a
214 </p>
215 <pre> b 
216 </pre>
217 <p>c
218 </p>
219 !! end
222 ### Preformatted text
224 !! test
225 Preformatted text
226 !! input
227  This is some
228  Preformatted text
229  With ''italic''
230  And '''bold'''
231  And a [[Main Page|link]]
232 !! result
233 <pre>This is some
234 Preformatted text
235 With <i>italic</i>
236 And <b>bold</b>
237 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
238 </pre>
239 !! end
242 ### Definition lists
244 !! test
245 Simple definition
246 !! input
247 ; name : Definition
248 !! result
249 <dl><dt> name&nbsp;</dt><dd> Definition
250 </dd></dl>
252 !! end
254 !! test
255 Simple definition
256 !! input
257 : Indented text
258 !! result
259 <dl><dd> Indented text
260 </dd></dl>
262 !! end
264 !! test
265 Definition list with no space
266 !! input
267 ;name:Definition
268 !! result
269 <dl><dt>name</dt><dd>Definition
270 </dd></dl>
272 !!end
274 !! test
275 Definition list with URL link
276 !! input
277 ; http://example.com/ : definition
278 !! result
279 <dl><dt> <a href="http://example.com/" class='external free' title="http://example.com/" rel="nofollow">http://example.com/</a>&nbsp;</dt><dd> definition
280 </dd></dl>
282 !! end
284 !! test
285 Definition list with bracketed URL link
286 !! input
287 ;[http://www.google.com/ Google]:Number one search engine
288 !! result
289 <dl><dt><a href="http://www.google.com/" class='external text' title="http://www.google.com/" rel="nofollow">Google</a></dt><dd>Number one search engine
290 </dd></dl>
292 !! end
294 !! test
295 Definition list with wikilink containing colon
296 !! input
297 ; [[Help:FAQ]]: The least-read page on Wikipedia
298 !! result
299 <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
300 </dd></dl>
302 !! end
304 # At Brion's and JeLuF's insistence... :)
305 !! test
306 Definition list with wikilink containing colon
307 !! input
308 ;  news:alt.wikipedia.rox: This isn't even a real newsgroup!
309 !! result
310 <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!
311 </dd></dl>
313 !! end
315 !! test
316 Malformed definition list with colon
317 !! input
318 ;  news:alt.wikipedia.rox -- don't crash or enter an infinite loop
319 !! result
320 <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
321 </dt></dl>
323 !! end
325 !! test
326 Definition lists: colon in external link text
327 !! input
328 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
329 !! result
330 <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
331 </dd></dl>
333 !! end
337 ### External links
339 !! test
340 External links: non-bracketed
341 !! input
342 Non-bracketed: http://example.com
343 !! result
344 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
345 </p>
346 !! end
348 !! test
349 External links: numbered
350 !! input
351 Numbered: [http://example.com]
352 Numbered: [http://example.net]
353 Numbered: [http://example.org]
354 !! result
355 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
356 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
357 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
358 </p>
359 !!end
361 !! test
362 External links: specified text
363 !! input
364 Specified text: [http://example.com link]
365 !! result
366 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
367 </p>
368 !!end
370 !! test
371 External links: trail
372 !! input
373 Linktrails should not work for external links: [http://example.com link]s
374 !! result
375 <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
376 </p>
377 !! end
379 !! test
380 External links: dollar sign in URL
381 !! input
382 http://example.com/1$2345
383 !! result
384 <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>
385 </p>
386 !! end
388 !! test
389 External links: dollar sign in URL (named)
390 !! input
391 [http://example.com/1$2345]
392 !! result
393 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
394 </p>
395 !!end
397 !! test
398 External image
399 !! input
400 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
401 !! result
402 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
403 </p>
404 !! end
406 !! test
407 External image from https
408 !! input
409 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
410 !! result
411 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
412 </p>
413 !! end
415 !! test
416 Link to non-http image, no img tag
417 !! input
418 Link to non-http image, no img tag: ftp://example.com/test.jpg
419 !! result
420 <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>
421 </p>
422 !! end
424 !! test
425 External links: terminating separator
426 !! input
427 Terminating separator: http://example.com/thing,
428 !! result
429 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
430 </p>
431 !! end
433 !! test
434 External links: intervening separator
435 !! input
436 Intervening separator: http://example.com/1,2,3
437 !! result
438 <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>
439 </p>
440 !! end
442 !! test
443 External links: old bug with URL in query
444 !! input
445 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
446 !! result
447 <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>
448 </p>
449 !! end
451 !! test
452 External links: old URL-in-URL bug, mixed protocols
453 !! input
454 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
455 !! result
456 <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>
457 </p>
458 !!end
460 !! test
461 External links: URL in text
462 !! input
463 URL in text: [http://example.com http://example.com]
464 !! result
465 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
466 </p>
467 !! end
469 !! test
470 External links: Clickable images
471 !! input
472 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
473 !! result
474 <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>
475 </p>
476 !!end
478 !! test
479 External links: raw ampersand
480 !! input
481 Old &amp; use: http://x&y
482 !! result
483 <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>
484 </p>
485 !! end
487 !! test
488 External links: encoded ampersand
489 !! input
490 Old &amp; use: http://x&amp;y
491 !! result
492 <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>
493 </p>
494 !! end
496 !! test
497 External links: [raw ampersand]
498 !! input
499 Old &amp; use: [http://x&y]
500 !! result
501 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
502 </p>
503 !! end
505 !! test
506 External links: [encoded ampersand]
507 !! input
508 Old &amp; use: [http://x&amp;y]
509 !! result
510 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
511 </p>
512 !! end
514 !! test
515 External links: www.jpeg.org (bug 554)
516 !! input
517 http://www.jpeg.org
518 !!result
519 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
520 </p>
521 !! end
523 !! test
524 External links: URL within URL (original bug 2)
525 !! input
526 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
527 !! result
528 <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>
529 </p>
530 !! end
532 !! test
533 BUG 361: URL inside bracketed URL
534 !! input
535 [http://www.example.com/foo http://www.example.com/bar]
536 !! result
537 <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>
538 </p>
539 !! end
541 !! test
542 BUG 361: URL within URL, not bracketed
543 !! input
544 http://www.example.com/foo?=http://www.example.com/bar
545 !! result
546 <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>
547 </p>
548 !! end
550 !! test
551 BUG 289: ">"-token in URL-tail
552 !! input
553 http://www.example.com/<hello>
554 !! result
555 <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;
556 </p>
557 !!end
559 !! test
560 BUG 289: literal ">"-token in URL-tail
561 !! input
562 http://www.example.com/<b>html</b>
563 !! result
564 <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>
565 </p>
566 !!end
568 !! test
569 BUG 289: ">"-token in bracketed URL
570 !! input
571 [http://www.example.com/<hello> stuff]
572 !! result
573 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
574 </p>
575 !!end
577 !! test
578 BUG 289: literal ">"-token in bracketed URL
579 !! input
580 [http://www.example.com/<b>html</b> stuff]
581 !! result
582 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
583 </p>
584 !!end
586 !! test
587 BUG 289: literal double quote at end of URL
588 !! input
589 http://www.example.com/"hello"
590 !! result
591 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
592 </p>
593 !!end
595 !! test
596 BUG 289: literal double quote in bracketed URL
597 !! input
598 [http://www.example.com/"hello" stuff]
599 !! result
600 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
601 </p>
602 !!end
604 !! test
605 External links: invalid character
606 !! input
607 [http://www.example.com\0 test]
608 !! result
609 <p>[<a href="http://www.example.com" class='external free' title="http://www.example.com" rel="nofollow">http://www.example.com</a>\0 test]
610 </p>
611 !! end
613 !! test
614 BUG 787: Links with one slash after the url protocol are invalid
615 !! input
616 http:/example.com
618 [http:/example.com title]
619 !! result
620 <p>http:/example.com
621 </p><p>
622 [http:/example.com title]
623 </p>
624 !! end
627 ### Quotes
630 !! test
631 Quotes
632 !! input
633 Normal text. '''Bold text.''' Normal text. ''Italic text.''
635 Normal text. '''''Bold italic text.''''' Normal text.
636 !!result
637 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
638 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
639 </p>
640 !! end
643 !! test
644 Unclosed and unmatched quotes
645 !! input
646 '''''Bold italic text '''with bold deactivated''' in between.'''''
648 '''''Bold italic text ''with italic deactivated'' in between.'''''
650 '''Bold text..
652 ..spanning two paragraphs (should not work).'''
654 '''Bold tag left open
656 ''Italic tag left open
658 Normal text.
660 <!-- Unmatching number of opening, closing tags: -->
661 '''This year''''s election ''should'' beat '''last year''''s.
663 ''Tom'''s car is bigger than ''Susan'''s.
664 !! result
665 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
666 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
667 </p><p><b>Bold text..</b>
668 </p><p>..spanning two paragraphs (should not work).<b></b>
669 </p><p><b>Bold tag left open</b>
670 </p><p><i>Italic tag left open</i>
671 </p><p>Normal text.
672 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
673 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
674 </p>
675 !! end
678 ### Tables
680 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
683 # This should not produce <table></table> as <table><tr><td></td></tr></table>
684 # is the bare minimun required by the spec, see:
685 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
686 !! test
687 A table with no data.
688 !! input
689 {||}
690 !! result
691 !! end
693 # A table with nothing but a caption is invalid XHTML, we might want to render
694 # this as <p>caption</p>
695 !! test
696 A table with nothing but a caption
697 !! input 
699 |+ caption
701 !! result
702 <table>
703 <caption> caption
704 </caption>
705 <tr>
706 <td>
707 </td></tr></table>
708 !! end
710 !! test
711 Simple table
712 !! input
713 {| 
714 | 1 || 2
715 |- 
716 | 3 || 4
718 !! result
719 <table>
720 <tr>
721 <td> 1 </td><td> 2
722 </td></tr>
723 <tr>
724 <td> 3 </td><td> 4
725 </td></tr></table>
727 !! end
729 !! test
730 Multiplication table
731 !! input
732 {| border="1" cellpadding="2"
733 |+Multiplication table
735 ! &times; !! 1 !! 2 !! 3
737 ! 1
738 | 1 || 2 || 3
740 ! 2
741 | 2 || 4 || 6
743 ! 3
744 | 3 || 6 || 9
746 ! 4
747 | 4 || 8 || 12
749 ! 5
750 | 5 || 10 || 15
752 !! result
753 <table border="1" cellpadding="2">
754 <caption>Multiplication table
755 </caption>
756 <tr>
757 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
758 </th></tr>
759 <tr>
760 <th> 1
761 </th><td> 1 </td><td> 2 </td><td> 3
762 </td></tr>
763 <tr>
764 <th> 2
765 </th><td> 2 </td><td> 4 </td><td> 6
766 </td></tr>
767 <tr>
768 <th> 3
769 </th><td> 3 </td><td> 6 </td><td> 9
770 </td></tr>
771 <tr>
772 <th> 4
773 </th><td> 4 </td><td> 8 </td><td> 12
774 </td></tr>
775 <tr>
776 <th> 5
777 </th><td> 5 </td><td> 10 </td><td> 15
778 </td></tr></table>
780 !! end
782 !! test
783 Table rowspan
784 !! input
785 {| align=right border=1
786 | Cell 1, row 1 
787 |rowspan=2| Cell 2, row 1 (and 2) 
788 | Cell 3, row 1 
789 |- 
790 | Cell 1, row 2 
791 | Cell 3, row 2 
793 !! result
794 <table align="right" border="1">
795 <tr>
796 <td> Cell 1, row 1
797 </td><td rowspan="2"> Cell 2, row 1 (and 2)
798 </td><td> Cell 3, row 1
799 </td></tr>
800 <tr>
801 <td> Cell 1, row 2
802 </td><td> Cell 3, row 2
803 </td></tr></table>
805 !! end
807 !! test
808 Nested table
809 !! input
810 {| border=1
811 | &alpha;
813 {| bgcolor=#ABCDEF border=2
814 |nested
816 |table
818 |the original table again
820 !! result
821 <table border="1">
822 <tr>
823 <td> &alpha;
824 </td><td>
825 <table bgcolor="#ABCDEF" border="2">
826 <tr>
827 <td>nested
828 </td></tr>
829 <tr>
830 <td>table
831 </td></tr></table>
832 </td><td>the original table again
833 </td></tr></table>
835 !! end
837 !! test
838 Invalid attributes in table cell (bug 1830)
839 !! input
841 |Cell:|broken
843 !! result
844 <table>
845 <tr>
846 <td>broken
847 </td></tr></table>
849 !! end
853 ### Internal links
855 !! test
856 Plain link, capitalized
857 !! input
858 [[Main Page]]
859 !! result
860 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
861 </p>
862 !! end
864 !! test
865 Plain link, uncapitalized
866 !! input
867 [[main Page]]
868 !! result
869 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
870 </p>
871 !! end
873 !! test
874 Piped link
875 !! input
876 [[Main Page|The Main Page]]
877 !! result
878 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
879 </p>
880 !! end
882 !! test
883 Broken link
884 !! input
885 [[Zigzagzogzagzig]]
886 !! result
887 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
888 </p>
889 !! end
891 !! test
892 Link with prefix
893 !! input
894 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
895 !! result
896 <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>
897 </p>
898 !! end
900 !! test
901 Link with suffix
902 !! input
903 [[Main Page]]xxx, [[Main Page]]XXX
904 !! result
905 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
906 </p>
907 !! end
909 !! test
910 Link with 3 brackets
911 !! input
912 [[[main page]]]
913 !! result
914 <p>[[[main page]]]
915 </p>
916 !! end
918 !! test
919 Piped link with 3 brackets
920 !! input
921 [[[main page|the main page]]]
922 !! result
923 <p>[[[main page|the main page]]]
924 </p>
925 !! end
927 !! test
928 Link with multiple pipes
929 !! input
930 [[Main Page|The|Main|Page]]
931 !! result
932 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
933 </p>
934 !! end
936 !! test
937 Link to namespaces
938 !! input
939 [[Talk:Parser testing]], [[Meta:Disclaimers]]
940 !! result
941 <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>
942 </p>
943 !! end
945 !! test
946 Piped link to namespace
947 !! input
948 [[Meta:Disclaimers|The disclaimers]]
949 !! result
950 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
951 </p>
952 !! end
954 !! test
955 Link containing }
956 !! input
957 [[Usually caused by a typo (oops}]]
958 !! result
959 <p>[[Usually caused by a typo (oops}]]
960 </p>
961 !! end
963 !! test
964 Link containing % (not as a hex sequence)
965 !! input
966 [[7% Solution]]
967 !! result
968 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
969 </p>
970 !! end
972 !! test
973 Link containing % as a single hex sequence interpreted to char
974 !! input
975 [[7%25 Solution]]
976 !! result
977 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
978 </p>
979 !!end
981 !! test
982 Link containing % as a double hex sequence interpreted to hex sequence
983 !! input
984 [[7%2525 Solution]]
985 !! result
986 <p>[[7%2525 Solution]]
987 </p>
988 !!end
990 !! test
991 Plain link to URL
992 !! input
993 [[http://www.example.org]]
994 !! result
995 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
996 </p>
997 !! end
999 # I'm fairly sure the expected result here is wrong.
1000 # We want these to be URL links, not pseudo-pages with URLs for titles....
1001 # However the current output is also pretty screwy.
1003 # ----
1004 # I'm changing it to match the current output--it arguably makes more
1005 # sense in the light of the test above. Old expected result was:
1006 #<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>
1007 #</p>
1008 # But I think this test is bordering on "garbage in, garbage out" anyway.
1009 # -- wtm
1010 !! test
1011 Piped link to URL
1012 !! input
1013 Piped link to URL: [[http://www.example.org|an example URL]]
1014 !! result
1015 <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>]
1016 </p>
1017 !! end
1019 !! test
1020 BUG 2: [[page|http://url/]] should link to page, not http://url/
1021 !! input
1022 [[Main Page|http://url/]]
1023 !! result
1024 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1025 </p>
1026 !! end
1028 !! test
1029 BUG 337: Escaped self-links should be bold
1030 !! options
1031 title=[[Bug462]]
1032 !! input
1033 [[Bu&#103;462]] [[Bug462]]
1034 !! result
1035 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1036 </p>
1037 !! end
1039 !! test
1040 Self-link to section should not be bold
1041 !! options
1042 title=[[Main Page]]
1043 !! input
1044 [[Main Page#section]]
1045 !! result
1046 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1047 </p>
1048 !! end
1050 !! test
1051 <nowiki> inside a link
1052 !! input
1053 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1054 !! result
1055 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
1056 </p>
1057 !! end
1060 ### Interwiki links (see maintenance/interwiki.sql)
1063 !! test
1064 Inline interwiki link
1065 !! input
1066 [[MeatBall:SoftSecurity]]
1067 !! result
1068 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity</a>
1069 </p>
1070 !! end
1072 !! test
1073 Inline interwiki link with empty title (bug 2372)
1074 !! input
1075 [[MeatBall:]]
1076 !! result
1077 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="MeatBall:">MeatBall:</a>
1078 </p>
1079 !! end
1081 !! test
1082 Interwiki link encoding conversion (bug 1636)
1083 !! input
1084 *[[Wikipedia:ro:Olteni&#0355;a]]
1085 *[[Wikipedia:ro:Olteni&#355;a]]
1086 !! result
1087 <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>
1088 </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>
1089 </li></ul>
1091 !! end
1093 !! test
1094 Interwiki link with fragment (bug 2130)
1095 !! input
1096 [[MeatBall:SoftSecurity#foo]]
1097 !! result
1098 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1099 </p>
1100 !! end
1103 ## XHTML tidiness
1106 !! test
1107 <br> to <br />
1108 !! input
1109 1<br>2<br />3
1110 !! result
1111 <p>1<br />2<br />3
1112 </p>
1113 !! end
1115 !! test
1116 Incorrecly removing closing slashes from correctly formed XHTML
1117 !! input
1118 <br style="clear:both;" />
1119 !! result
1120 <p><br style="clear:both;" />
1121 </p>
1122 !! end
1124 !! test 
1125 Failing to transform badly formed HTML into correct XHTML
1126 !! input
1127 <br clear=left>
1128 <br clear=right>
1129 <br clear=all>
1130 !! result
1131 <p><br style="clear:left;" />
1132 <br style="clear:right;" />
1133 <br style="clear:both;" />
1134 </p>
1135 !!end
1137 !! test 
1138 Horizontal ruler (should it add that extra space?)
1139 !! input 
1140 <hr>
1141 <hr >
1142 foo <hr
1143 > bar
1144 !! result 
1145 <hr />
1146 <hr />
1147 foo <hr /> bar
1148 !! end
1151 ### Block-level elements
1153 !! test
1154 Common list
1155 !! input
1156 *Common list
1157 * item 2
1158 *item 3
1159 !! result
1160 <ul><li>Common list
1161 </li><li> item 2
1162 </li><li>item 3
1163 </li></ul>
1165 !! end
1167 !! test
1168 Numbered list
1169 !! input
1170 #Numbered list
1171 #item 2
1172 # item 3
1173 !! result
1174 <ol><li>Numbered list
1175 </li><li>item 2
1176 </li><li> item 3
1177 </li></ol>
1179 !! end
1181 !! test
1182 Mixed list
1183 !! input
1184 *Mixed list
1185 *# with numbers
1186 ** and bullets
1187 *# and numbers
1188 *bullets again
1189 **bullet level 2
1190 ***bullet level 3
1191 ***#Number on level 4
1192 **bullet level 2
1193 **#Number on level 3
1194 **#Number on level 3
1195 *#number level 2
1196 *Level 1
1197 !! result
1198 <ul><li>Mixed list
1199 <ol><li> with numbers
1200 </li></ol>
1201 <ul><li> and bullets
1202 </li></ul>
1203 <ol><li> and numbers
1204 </li></ol>
1205 </li><li>bullets again
1206 <ul><li>bullet level 2
1207 <ul><li>bullet level 3
1208 <ol><li>Number on level 4
1209 </li></ol>
1210 </li></ul>
1211 </li><li>bullet level 2
1212 <ol><li>Number on level 3
1213 </li><li>Number on level 3
1214 </li></ol>
1215 </li></ul>
1216 <ol><li>number level 2
1217 </li></ol>
1218 </li><li>Level 1
1219 </li></ul>
1221 !! end
1223 !! test
1224 List items are not parsed correctly following a <pre> block (bug 785)
1225 !! input
1226 * <pre>foo</pre>
1227 * <pre>bar</pre>
1228 * zar
1229 !! result
1230 <ul><li> <pre>foo</pre>
1231 </li><li> <pre>bar</pre>
1232 </li><li> zar
1233 </li></ul>
1235 !! end
1238 ### Magic variables
1240 !! test
1241 Magic variables
1242 !! input
1243 {{SITENAME}}
1244 !! result
1245 <p>MediaWiki
1246 </p>
1247 !! end
1250 ### Magic links
1252 !! test
1253 Magic links: internal link to RFC (bug 479)
1254 !! input
1255 [[RFC 123]]
1256 !! result
1257 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1258 </p>
1259 !! end
1261 !! test
1262 Magic links: RFC (bug 479)
1263 !! input
1264 RFC 822
1265 !! result
1266 <p><a href='http://www.faqs.org/rfcs/rfc822.html' class='external' title="http://www.faqs.org/rfcs/rfc822.html">RFC 822</a>
1267 </p>
1268 !! end
1270 !! test
1271 Magic links: ISBN (bug 1937)
1272 !! input
1273 ISBN 0-306-40615-2
1274 !! result
1275 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1276 </p>
1277 !! end
1279 !! test
1280 Magic links: PMID incorrectly converts space to underscore
1281 !! input
1282 PMID 1234
1283 !! result
1284 <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>
1285 </p>
1286 !! end
1289 ### Templates
1290 ####
1292 !! test
1293 Nonexistant template
1294 !! input
1295 {{thistemplatedoesnotexist}}
1296 !! result
1297 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1298 </p>
1299 !! end
1301 !! article
1302 Template:test
1303 !! text
1304 This is a test template
1305 !! endarticle
1307 !! test
1308 Simple template
1309 !! input
1310 {{test}}
1311 !! result
1312 <p>This is a test template
1313 </p>
1314 !! end
1316 !! test
1317 Template with explicit namespace
1318 !! input
1319 {{Template:test}}
1320 !! result
1321 <p>This is a test template
1322 </p>
1323 !! end
1326 !! article
1327 Template:paramtest
1328 !! text
1329 This is a test template with parameter {{{param}}}
1330 !! endarticle
1332 !! test
1333 Template parameter
1334 !! input
1335 {{paramtest|param=foo}}
1336 !! result
1337 <p>This is a test template with parameter foo
1338 </p>
1339 !! end
1341 !! article
1342 Template:paramtestnum
1343 !! text
1344 [[{{{1}}}|{{{2}}}]]
1345 !! endarticle
1347 !! test
1348 Template unnamed parameter
1349 !! input
1350 {{paramtestnum|Main Page|the main page}}
1351 !! result
1352 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1353 </p>
1354 !! end
1356 !! test
1357 BUG 553: link with two variables in a piped link
1358 !! input
1359 {| 
1360 |[[{{{1}}}|{{{2}}}]]
1362 !! result
1363 <table>
1364 <tr>
1365 <td>[[{{{1}}}|{{{2}}}]]
1366 </td></tr></table>
1368 !! end
1370 !! test
1371 Magic variable as template parameter
1372 !! input
1373 {{paramtest|param={{SITENAME}}}}
1374 !! result
1375 <p>This is a test template with parameter MediaWiki
1376 </p>
1377 !! end
1379 !! article
1380 Template:linktest
1381 !! text
1382 [[{{{param}}}|link]]
1383 !! endarticle
1385 !! test
1386 Template parameter as link source
1387 !! input
1388 {{linktest|param=Main Page}}
1389 !! result
1390 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1391 </p>
1392 !! end
1395 !!article
1396 Template:paramtest2
1397 !! text
1398 including another template, {{paramtest|param={{{arg}}}}}
1399 !! endarticle
1401 !! test
1402 Template passing argument to another template
1403 !! input
1404 {{paramtest2|arg='hmm'}}
1405 !! result
1406 <p>including another template, This is a test template with parameter 'hmm'
1407 </p>
1408 !! end
1410 !! article
1411 Template:Linktest2
1412 !! text
1413 Main Page
1414 !! endarticle
1416 !! test
1417 Template as link source
1418 !! input
1419 [[{{linktest2}}]]
1420 !! result
1421 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1422 </p>
1423 !! end
1426 !! article
1427 Template:loop1
1428 !! text
1429 {{loop2}}
1430 !! endarticle
1432 !! article
1433 Template:loop2
1434 !! text
1435 {{loop1}}
1436 !! endarticle
1438 !! test
1439 Template infinite loop
1440 !! input
1441 {{loop1}}
1442 !! result
1443 <p>{{loop1}}<!-- WARNING: template loop detected -->
1444 </p>
1445 !! end
1447 !! test
1448 Template from main namespace
1449 !! input
1450 {{:Main Page}}
1451 !! result
1452 <p>blah blah
1453 </p>
1454 !! end
1456 !! article
1457 Template:table
1458 !! text
1459 {| 
1460 | 1 || 2
1461 |- 
1462 | 3 || 4
1464 !! endarticle
1466 !! test
1467 BUG 529: Template with table, not included at beginning of line
1468 !! input
1469 foo {{table}}
1470 !! result
1471 <p>foo 
1472 </p>
1473 <table>
1474 <tr>
1475 <td> 1 </td><td> 2
1476 </td></tr>
1477 <tr>
1478 <td> 3 </td><td> 4
1479 </td></tr></table>
1481 !! end
1483 !! test
1484 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1485 !! input
1487 {{table}}
1488 !! result
1489 <p>foo
1490 </p>
1491 <table>
1492 <tr>
1493 <td> 1 </td><td> 2
1494 </td></tr>
1495 <tr>
1496 <td> 3 </td><td> 4
1497 </td></tr></table>
1499 !! end
1501 !! test
1502 BUG 41: Template parameters shown as broken links
1503 !! input
1504 {{{parameter}}}
1505 !! result
1506 <p>{{{parameter}}}
1507 </p>
1508 !! end
1511 !! article
1512 Template:MSGNW test
1513 !! text
1514 ''None'' of '''this''' should be 
1515 * interepreted
1516  but rather passed unmodified
1517 {{test}}
1518 !! endarticle
1520 # hmm, fix this or just deprecate msgnw and document its behavior?
1521 !! test
1522 msgnw keyword
1523 !! options
1524 disabled
1525 !! input
1526 {{msgnw:MSGNW test}}
1527 !! result
1528 <p>''None'' of '''this''' should be 
1529 * interepreted
1530  but rather passed unmodified
1531 {{test}}
1532 </p>
1533 !! end
1535 !! test
1536 int keyword
1537 !! input
1538 {{int:newmessages|lots of money}}
1539 !! result
1540 <p>You have lots of money.
1541 </p>
1542 !! end
1545 ### Pre-save transform tests
1547 !! test
1548 pre-save transform: subst:
1549 !! options
1551 !! input
1552 {{subst:test}}
1553 !! result
1554 This is a test template
1555 !! end
1557 !! test
1558 pre-save transform: normal template
1559 !! options
1561 !! input
1562 {{test}}
1563 !! result
1564 {{test}}
1565 !! end
1567 !! test
1568 pre-save transform: nonexistant template
1569 !! options
1571 !! input
1572 {{thistemplatedoesnotexist}}
1573 !! result
1574 {{thistemplatedoesnotexist}}
1575 !! end
1578 !! test
1579 pre-save transform: subst magic variables
1580 !! options
1582 !! input
1583 {{subst:SITENAME}}
1584 !! result
1585 MediaWiki
1586 !! end
1588 # This is bug 89, which I fixed. -- wtm
1589 !! test
1590 pre-save transform: subst: templates with parameters
1591 !! options
1593 !! input
1594 {{subst:paramtest|param="something else"}}
1595 !! result
1596 This is a test template with parameter "something else"
1597 !! end
1600 !! article
1601 Template:nowikitest
1602 !! text
1603 <nowiki>'''not wiki'''</nowiki>
1604 !! endarticle
1606 !! test
1607 pre-save transform: nowiki in subst (bug 1188)
1608 !! options
1610 !! input
1611 {{subst:nowikitest}}
1612 !! result
1613 <nowiki>'''not wiki'''</nowiki>
1614 !! end
1617 !! article
1618 Template:commenttest
1619 !! text
1620 This template has <!-- a comment --> in it.
1621 !! endarticle
1623 !! test
1624 pre-save transform: comment in subst (bug 1936)
1625 !! options
1627 !! input
1628 {{subst:commenttest}}
1629 !! result
1630 This template has <!-- a comment --> in it.
1631 !! end
1634 !! article
1635 Template:dangerous
1636 !!text
1637 <span onmouseover="alert('crap')">Oh no</span>
1638 !!endarticle
1640 !!test
1641 (confirming safety of fix for subst bug 1936)
1642 !! input
1643 {{Template:dangerous}}
1644 !! result
1645 <p><span>Oh no</span>
1646 </p>
1647 !! end
1651 ### Message transform tests
1653 !! test
1654 message transform: magic variables
1655 !! options
1657 !! input
1658 {{SITENAME}}
1659 !! result
1660 MediaWiki
1661 !! end
1663 !! test
1664 message transform: should not transform wiki markup
1665 !! options
1667 !! input
1668 ''test''
1669 !! result
1670 ''test''
1671 !! end
1674 ### Images
1676 !! test
1677 Simple image
1678 !! input
1679 [[Image:foobar.jpg]]
1680 !! result
1681 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" /></a>
1682 </p>
1683 !! end
1685 !! test
1686 Right-aligned image
1687 !! input
1688 [[Image:foobar.jpg|right]]
1689 !! result
1690 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="/images/3/3a/Foobar.jpg" alt="" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1692 !! end
1694 !! test
1695 Image with caption
1696 !! input
1697 [[Image:foobar.jpg|right|Caption text]]
1698 !! result
1699 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img src="/images/3/3a/Foobar.jpg" alt="Caption text" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1701 !! end
1703 !! test
1704 Image with frame and link
1705 !! input
1706 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1707 !! result
1708 <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="/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>
1710 !! end
1712 !! test
1713 Link to image page
1714 !! input
1715 [[:Image:test]]
1716 !! result
1717 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1718 </p>
1719 !! end
1721 !! test
1722 Frameless image caption with a free URL
1723 !! input
1724 [[Image:foobar.jpg|http://example.com]]
1725 !! result
1726 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="/images/3/3a/Foobar.jpg" alt="http://example.com" longdesc="/wiki/Image:Foobar.jpg" /></a>
1727 </p>
1728 !! end
1730 !! test
1731 Thumbnail image caption with a free URL
1732 !! input
1733 [[Image:foobar.jpg|thumb|http://example.com]]
1734 !! result
1735 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img src="/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>
1737 !! end
1739 !! test
1740 BUG 1887: A ISBN with a thumbnail
1741 !! input
1742 [[Image:foobar.jpg|thumb|ISBN 12354]]
1743 !! result
1744 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="ISBN 12354"><img src="/images/3/3a/Foobar.jpg" alt="ISBN 12354" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></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>
1745 !! end
1747 !! test
1748 BUG 1887: A <math> with a thumbnail
1749 !! input
1750 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
1751 !! result
1752 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="2+2"><img src="/images/3/3a/Foobar.jpg" alt="2+2" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></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>
1753 !! end
1755 # Pending resolution to bug 368
1756 !! test
1757 BUG 648: Frameless image caption with a link
1758 !! input
1759 [[Image:foobar.jpg|text with a [[link]] in it]]
1760 !! result
1761 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a link in it" longdesc="/wiki/Image:Foobar.jpg" /></a>
1762 </p>
1763 !! end
1765 !! test
1766 BUG 648: Frameless image caption with a link (suffix)
1767 !! input
1768 [[Image:foobar.jpg|text with a [[link]]foo in it]]
1769 !! result
1770 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a linkfoo in it" longdesc="/wiki/Image:Foobar.jpg" /></a>
1771 </p>
1772 !! end
1774 !! test
1775 BUG 648: Frameless image caption with an interwiki link
1776 !! input
1777 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
1778 !! result
1779 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a MeatBall:Link in it" longdesc="/wiki/Image:Foobar.jpg" /></a>
1780 </p>
1781 !! end
1783 !! test
1784 BUG 648: Frameless image caption with a piped interwiki link
1785 !! input
1786 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
1787 !! result
1788 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a link in it" longdesc="/wiki/Image:Foobar.jpg" /></a>
1789 </p>
1790 !! end
1792 !! test
1793 Escape HTML special chars in image alt text
1794 !! input
1795 [[Image:foobar.jpg|& < > "]]
1796 !! result
1797 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="/images/3/3a/Foobar.jpg" alt="&amp; &lt; &gt; &quot;" longdesc="/wiki/Image:Foobar.jpg" /></a>
1798 </p>
1799 !! end
1801 !! test
1802 BUG 499: Alt text should have &#1234;, not &amp;1234;
1803 !! input
1804 [[Image:foobar.jpg|&#9792;]]
1805 !! result
1806 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="/images/3/3a/Foobar.jpg" alt="&#9792;" longdesc="/wiki/Image:Foobar.jpg" /></a>
1807 </p>
1808 !! end
1810 !! test
1811 Broken image caption with link
1812 !! input
1813 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
1814 !! result
1815 <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.
1816 </p>
1817 !! end
1819 !! test
1820 Image caption containing another image
1821 !! input
1822 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
1823 !! result
1824 <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="/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>
1826 !! end
1828 !! test
1829 Image caption containing a newline
1830 !! input
1831 [[Image:Foobar.jpg|This
1832 *is some text]]
1833 !! result
1834 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img src="/images/3/3a/Foobar.jpg" alt="This *is some text" longdesc="/wiki/Image:Foobar.jpg" /></a>
1835 </p>
1836 !!end
1841 ### Subpages
1843 !! article
1844 Subpage test/subpage
1845 !! text
1847 !! endarticle
1849 !! test
1850 Subpage link
1851 !! options
1852 subpage title=[[Subpage test]]
1853 !! input
1854 [[/subpage]]
1855 !! result
1856 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1857 </p>
1858 !! end
1860 !! test
1861 Subpage noslash link
1862 !! options
1863 subpage title=[[Subpage test]]
1864 !!input
1865 [[/subpage/]]
1866 !! result
1867 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1868 </p>
1869 !! end
1871 !! test
1872 Disabled subpages
1873 !! input
1874 [[/subpage]]
1875 !! result
1876 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1877 </p>
1878 !! end
1880 !! test
1881 BUG 561: {{/Subpage}}
1882 !! options
1883 subpage title=[[Page]]
1884 !! input
1885 {{/Subpage}}
1886 !! result
1887 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1888 </p>
1889 !! end
1892 ### Categories
1894 !! article
1895 Category:MediaWiki User's Guide
1896 !! text
1897 blah
1898 !! endarticle
1900 !! test
1901 Link to category
1902 !! input
1903 [[:Category:MediaWiki User's Guide]]
1904 !! result
1905 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1906 </p>
1907 !! end
1909 !! test
1910 Simple category
1911 !! options
1913 !! input
1914 [[Category: MediaWiki User's Guide]]
1915 !! result
1916 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1917 !! end
1920 ### Inter-language links
1922 !! test
1923 Inter-language links
1924 !! options
1926 !! input
1927 [[es:Alimento]]
1928 [[fr:Nourriture]]
1929 [[zh:&#39135;&#21697;]]
1930 !! result
1931 es:Alimento fr:Nourriture zh:食品
1932 !! end
1935 ### Sections
1937 !! test
1938 Basic section headings
1939 !! options
1940 title=[[Parser test script]]
1941 !! input
1942 == Headline 1 ==
1943 Some text
1945 ==Headline 2==
1946 More
1947 ===Smaller headline===
1948 Blah blah
1949 !! result
1950 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
1951 <p>Some text
1952 </p>
1953 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2>Headline 2</h2>
1954 <p>More
1955 </p>
1956 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Smaller_headline"></a><h3>Smaller headline</h3>
1957 <p>Blah blah
1958 </p>
1959 !! end
1961 !! test
1962 Section headings with TOC
1963 !! options
1964 title=[[Parser test script]]
1965 !! input
1966 == Headline 1 ==
1967 === Subheadline 1 ===
1968 ===== Skipping a level =====
1969 ====== Skipping a level ======
1971 == Headline 2 ==
1972 Some text
1973 ===Another headline===
1974 !! result
1975 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Table of contents</h2></div>
1976 <ul>
1977 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
1978 <ul>
1979 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
1980 <ul>
1981 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
1982 <ul>
1983 <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>
1984 </ul>
1985 </li>
1986 </ul>
1987 </li>
1988 </ul>
1989 </li>
1990 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
1991 <ul>
1992 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
1993 </ul>
1994 </li>
1995 </ul>
1996 </td></tr></table>
1997 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
1998 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
1999 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Subheadline_1"></a><h3> Subheadline 1 </h3>
2000 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Skipping_a_level"></a><h5> Skipping a level </h5>
2001 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=4" title="Parser test script">edit</a>]</div><a name="Skipping_a_level_2"></a><h6> Skipping a level </h6>
2002 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=5" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2> Headline 2 </h2>
2003 <p>Some text
2004 </p>
2005 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=6" title="Parser test script">edit</a>]</div><a name="Another_headline"></a><h3>Another headline</h3>
2007 !! end
2009 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2010 !! test
2011 Handling of sections up to level 6 and beyond
2012 !! input 
2013 = Level 1 Heading=
2014 == Level 2 Heading==
2015 === Level 3 Heading===
2016 ==== Level 4 Heading====
2017 ===== Level 5 Heading=====
2018 ====== Level 6 Heading======
2019 ======= Level 7 Heading=======
2020 ======== Level 8 Heading========
2021 ========= Level 9 Heading=========
2022 ========== Level 10 Heading==========
2023 !! result
2024 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Table of contents</h2></div>
2025 <ul>
2026 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2027 <ul>
2028 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2029 <ul>
2030 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2031 <ul>
2032 <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>
2033 <ul>
2034 <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>
2035 <ul>
2036 <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>
2037 <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>
2038 <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>
2039 <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>
2040 <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>
2041 </ul>
2042 </li>
2043 </ul>
2044 </li>
2045 </ul>
2046 </li>
2047 </ul>
2048 </li>
2049 </ul>
2050 </li>
2051 </ul>
2052 </td></tr></table>
2053 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2054 </p>
2055 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Parser test">edit</a>]</div><a name="Level_1_Heading"></a><h1> Level 1 Heading</h1>
2056 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Parser test">edit</a>]</div><a name="Level_2_Heading"></a><h2> Level 2 Heading</h2>
2057 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Parser test">edit</a>]</div><a name="Level_3_Heading"></a><h3> Level 3 Heading</h3>
2058 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Parser test">edit</a>]</div><a name="Level_4_Heading"></a><h4> Level 4 Heading</h4>
2059 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Parser test">edit</a>]</div><a name="Level_5_Heading"></a><h5> Level 5 Heading</h5>
2060 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Parser test">edit</a>]</div><a name="Level_6_Heading"></a><h6> Level 6 Heading</h6>
2061 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Parser test">edit</a>]</div><a name=".3D_Level_7_Heading.3D"></a><h6>= Level 7 Heading=</h6>
2062 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Parser test">edit</a>]</div><a name=".3D.3D_Level_8_Heading.3D.3D"></a><h6>== Level 8 Heading==</h6>
2063 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Parser test">edit</a>]</div><a name=".3D.3D.3D_Level_9_Heading.3D.3D.3D"></a><h6>=== Level 9 Heading===</h6>
2064 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Parser test">edit</a>]</div><a name=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"></a><h6>==== Level 10 Heading====</h6>
2066 !! end
2068 !! test
2069 Resolving duplicate section names
2070 !! options
2071 title=[[Parser test script]]
2072 !! input
2073 == Foo bar ==
2074 == Foo bar ==
2075 !! result
2076 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Foo_bar"></a><h2> Foo bar </h2>
2077 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Foo_bar_2"></a><h2> Foo bar </h2>
2079 !! end
2081 !! article
2082 Template:sections
2083 !! text
2084 ===Section 1===
2085 ==Section 2==
2086 !! endarticle
2088 !! test
2089 Template with sections, __NOTOC__
2090 !! options
2091 title=[[Parser test script]]
2092 !! input
2093 __NOTOC__
2094 ==Section 0==
2095 {{sections}}
2096 ==Section 4==
2097 !! result
2098 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Section_0"></a><h2>Section 0</h2>
2099 <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>
2100 <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>
2101 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Section_4"></a><h2>Section 4</h2>
2103 !! end
2105 !! test
2106 __NOEDITSECTION__ keyword
2107 !! input
2108 __NOEDITSECTION__
2109 ==Section 1==
2110 ==Section 2==
2111 !! result
2112 <a name="Section_1"></a><h2>Section 1</h2>
2113 <a name="Section_2"></a><h2>Section 2</h2>
2115 !! end
2117 !! test
2118 Link inside a section heading
2119 !! options
2120 title=[[Parser test script]]
2121 !! input
2122 ==Section with a [[Main Page|link]] in it==
2123 !! result
2124 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">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>
2126 !! end
2129 !! test
2130 Bug 1219 URL next to image (good)
2131 !! input
2132 http://example.com [[Image:foobar.jpg]]
2133 !! result
2134 <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="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" /></a>
2135 </p>
2136 !!end
2138 !! test
2139 Bug 1219 URL next to image (broken)
2140 !! input
2141 http://example.com[[Image:foobar.jpg]]
2142 !! result
2143 <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="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" /></a>
2144 </p>
2145 !!end
2147 !! test
2148 Bug 1186 news: in the middle of text
2149 !! input
2150 http://en.wikinews.org/wiki/Wikinews:Workplace
2151 !! result
2152 <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>
2153 </p>
2154 !!end
2157 !! test
2158 Namespaced link must have a title
2159 !! input
2160 [[Project:]]
2161 !! result
2162 <p>[[Project:]]
2163 </p>
2164 !!end
2166 !! test
2167 Namespaced link must have a title (bad fragment version)
2168 !! input
2169 [[Project:#fragment]]
2170 !! result
2171 <p>[[Project:#fragment]]
2172 </p>
2173 !!end
2176 !! test
2177 div with no attributes
2178 !! input
2179 <div>HTML rocks</div>
2180 !! result
2181 <div>HTML rocks</div>
2183 !! end
2185 !! test
2186 div with double-quoted attribute
2187 !! input
2188 <div id="rock">HTML rocks</div>
2189 !! result
2190 <div id="rock">HTML rocks</div>
2192 !! end
2194 !! test
2195 div with single-quoted attribute
2196 !! input
2197 <div id='rock'>HTML rocks</div>
2198 !! result
2199 <div id="rock">HTML rocks</div>
2201 !! end
2203 !! test
2204 div with unquoted attribute
2205 !! input
2206 <div id=rock>HTML rocks</div>
2207 !! result
2208 <div id="rock">HTML rocks</div>
2210 !! end
2212 !! test
2213 div with illegal double attributes
2214 !! input
2215 <div align="center" align="right">HTML rocks</div>
2216 !! result
2217 <div align="center">HTML rocks</div>
2219 !!end
2221 !! test
2222 DIV IN UPPERCASE
2223 !! input
2224 <DIV ALIGN="center">HTML ROCKS</DIV>
2225 !! result
2226 <div align="center">HTML ROCKS</div>
2228 !!end
2231 !! test
2232 text with amp in the middle of nowhere
2233 !! input
2234 Remember AT&T?
2235 !!result
2236 <p>Remember AT&amp;T?
2237 </p>
2238 !! end
2240 !! test
2241 text with character entity: eacute
2242 !! input
2243 I always thought &eacute; was a cute letter.
2244 !! result
2245 <p>I always thought &eacute; was a cute letter.
2246 </p>
2247 !! end
2249 !! test
2250 text with undefined character entity: xacute
2251 !! input
2252 I always thought &xacute; was a cute letter.
2253 !! result
2254 <p>I always thought &amp;xacute; was a cute letter.
2255 </p>
2256 !! end
2260 ### Media links
2263 !! test
2264 Media link
2265 !! input
2266 [[Media:Foobar.jpg]]
2267 !! result
2268 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2269 </p>
2270 !! end
2272 !! test
2273 Media link with text
2274 !! input
2275 [[Media:Foobar.jpg|A neat file to look at]]
2276 !! result
2277 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2278 </p>
2279 !! end
2281 # FIXME: this is still bad HTML tag nesting
2282 !! test
2283 Media link with nasty text
2284 !! input
2285 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2286 !! result
2287 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie) onfoo="</div></a>
2288 </p>
2289 !! end
2291 !! test
2292 Media link to nonexistent file (bug 1702)
2293 !! input
2294 [[Media:No such.jpg]]
2295 !! result
2296 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2297 </p>
2298 !! end
2302 !! test
2303 Character reference normalization in link text (bug 1938)
2304 !! input
2305 [[Main Page|this&that]]
2306 !! result
2307 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2308 </p>
2309 !!end
2311 !! test
2312 Empty attribute crash test (bug 2067)
2313 !! input
2314 <font color="">foo</font>
2315 !! result
2316 <p><font color="">foo</font>
2317 </p>
2318 !! end
2320 !! test
2321 Empty attribute crash test single-quotes (bug 2067)
2322 !! input
2323 <font color=''>foo</font>
2324 !! result
2325 <p><font color="">foo</font>
2326 </p>
2327 !! end
2329 !! test
2330 Attribute test: equals, then nothing
2331 !! input
2332 <font color=>foo</font>
2333 !! result
2334 <p><font>foo</font>
2335 </p>
2336 !! end
2338 !! test
2339 Attribute test: unquoted value
2340 !! input
2341 <font color=x>foo</font>
2342 !! result
2343 <p><font color="x">foo</font>
2344 </p>
2345 !! end
2347 !! test
2348 Attribute test: unquoted but illegal value (hash)
2349 !! input
2350 <font color=#x>foo</font>
2351 !! result
2352 <p><font color="#x">foo</font>
2353 </p>
2354 !! end
2356 !! test
2357 Attribute test: no value
2358 !! input
2359 <font color>foo</font>
2360 !! result
2361 <p><font color="color">foo</font>
2362 </p>
2363 !! end
2365 !! test
2366 Bug 2095: link with three closing brackets
2367 !! input
2368 [[Main Page]]]
2369 !! result
2370 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
2371 </p>
2372 !! end
2374 !! test
2375 Bug 2095: link with pipe and three closing brackets
2376 !! input
2377 [[Main Page|link]]]
2378 !! result
2379 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
2380 </p>
2381 !! end
2385 ### Safety
2388 !! article
2389 Template:Dangerous attribute
2390 !! text
2391 " onmouseover="alert(document.cookie)
2392 !! endarticle
2394 !! article
2395 Template:Dangerous style attribute
2396 !! text
2397 border-size: expression(alert(document.cookie))
2398 !! endarticle
2400 !! article
2401 Template:Div style
2402 !! text
2403 <div style="float: right; {{{1}}}">Magic div</div>
2404 !! endarticle
2406 !! test
2407 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
2408 !! input
2409 <div title="{{test}}"></div>
2410 !! result
2411 <div title="This is a test template"></div>
2413 !! end
2415 !! test
2416 Bug 2304: HTML attribute safety (dangerous template; 2309)
2417 !! input
2418 <div title="{{dangerous attribute}}"></div>
2419 !! result
2420 <div title=""></div>
2422 !! end
2424 !! test
2425 Bug 2304: HTML attribute safety (dangerous style template; 2309)
2426 !! input
2427 <div style="{{dangerous style attribute}}"></div>
2428 !! result
2429 <div></div>
2431 !! end
2433 !! test
2434 Bug 2304: HTML attribute safety (safe parameter; 2309)
2435 !! input
2436 {{div style|width: 200px}}
2437 !! result
2438 <div style="float: right; width: 200px">Magic div</div>
2440 !! end
2442 !! test
2443 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
2444 !! input
2445 {{div style|width: expression(alert(document.cookie))}}
2446 !! result
2447 <div>Magic div</div>
2449 !! end
2451 !! test
2452 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
2453 !! input
2454 {{div style|"><script>alert(document.cookie)</script>}}
2455 !! result
2456 <div>Magic div</div>
2458 !! end
2460 !! test
2461 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
2462 !! input
2463 {{div style|" ><script>alert(document.cookie)</script>}}
2464 !! result
2465 <div style="float: right; ">Magic div</div>
2467 !! end
2469 !! test
2470 Bug 2304: HTML attribute safety (link)
2471 !! input
2472 <div title="[[Main Page]]"></div>
2473 !! result
2474 <div title="&#91;&#91;Main Page]]"></div>
2476 !! end
2478 !! test
2479 Bug 2304: HTML attribute safety (italics)
2480 !! input
2481 <div title="''foobar''"></div>
2482 !! result
2483 <div title="&#39;&#39;foobar&#39;&#39;"></div>
2485 !! end
2487 !! test
2488 Bug 2304: HTML attribute safety (bold)
2489 !! input
2490 <div title="'''foobar'''"></div>
2491 !! result
2492 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
2494 !! end
2496 !! test
2497 Bug 2304: HTML attribute safety (ISBN)
2498 !! input
2499 <div title="ISBN 1234567890"></div>
2500 !! result
2501 <div title="&#73;SBN 1234567890"></div>
2503 !! end
2505 !! test
2506 Bug 2304: HTML attribute safety (RFC)
2507 !! input
2508 <div title="RFC 1234"></div>
2509 !! result
2510 <div title="&#82;FC 1234"></div>
2512 !! end
2514 !! test
2515 Bug 2304: HTML attribute safety (PMID)
2516 !! input
2517 <div title="PMID 1234567890"></div>
2518 !! result
2519 <div title="&#80;MID 1234567890"></div>
2521 !! end
2523 !! test
2524 Bug 2304: HTML attribute safety (web link)
2525 !! input
2526 <div title="http://example.com/"></div>
2527 !! result
2528 <div title="http&#58;//example.com/"></div>
2530 !! end
2532 !! test
2533 Bug 2304: HTML attribute safety (named web link)
2534 !! input
2535 <div title="[http://example.com/ link]"></div>
2536 !! result
2537 <div title="&#91;http&#58;//example.com/ link]"></div>
2539 !! end
2542 TODO:
2543 more images
2544 more tables
2545 math
2546 character entities
2547 and much more