* Fix talk page move handling
[mediawiki.git] / maintenance / parserTests.txt
blobc735504541b1732f22ad5f053ca26a0e784ec7b5
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
626 !! test
627 Bug 2702: Mismatched <i> and <a> tags are invalid
628 !! input
629 ''[http://example.com text'']
630 !! result
631 <p><i><a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">text</a></i>
632 </p>
633 !! end
636 ### Quotes
639 !! test
640 Quotes
641 !! input
642 Normal text. '''Bold text.''' Normal text. ''Italic text.''
644 Normal text. '''''Bold italic text.''''' Normal text.
645 !!result
646 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
647 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
648 </p>
649 !! end
652 !! test
653 Unclosed and unmatched quotes
654 !! input
655 '''''Bold italic text '''with bold deactivated''' in between.'''''
657 '''''Bold italic text ''with italic deactivated'' in between.'''''
659 '''Bold text..
661 ..spanning two paragraphs (should not work).'''
663 '''Bold tag left open
665 ''Italic tag left open
667 Normal text.
669 <!-- Unmatching number of opening, closing tags: -->
670 '''This year''''s election ''should'' beat '''last year''''s.
672 ''Tom'''s car is bigger than ''Susan'''s.
673 !! result
674 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
675 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
676 </p><p><b>Bold text..</b>
677 </p><p>..spanning two paragraphs (should not work).<b></b>
678 </p><p><b>Bold tag left open</b>
679 </p><p><i>Italic tag left open</i>
680 </p><p>Normal text.
681 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
682 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
683 </p>
684 !! end
687 ### Tables
689 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
692 # This should not produce <table></table> as <table><tr><td></td></tr></table>
693 # is the bare minimun required by the spec, see:
694 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
695 !! test
696 A table with no data.
697 !! input
698 {||}
699 !! result
700 !! end
702 # A table with nothing but a caption is invalid XHTML, we might want to render
703 # this as <p>caption</p>
704 !! test
705 A table with nothing but a caption
706 !! input 
708 |+ caption
710 !! result
711 <table>
712 <caption> caption
713 </caption>
714 <tr>
715 <td>
716 </td></tr></table>
717 !! end
719 !! test
720 Simple table
721 !! input
722 {| 
723 | 1 || 2
724 |- 
725 | 3 || 4
727 !! result
728 <table>
729 <tr>
730 <td> 1 </td><td> 2
731 </td></tr>
732 <tr>
733 <td> 3 </td><td> 4
734 </td></tr></table>
736 !! end
738 !! test
739 Multiplication table
740 !! input
741 {| border="1" cellpadding="2"
742 |+Multiplication table
744 ! &times; !! 1 !! 2 !! 3
746 ! 1
747 | 1 || 2 || 3
749 ! 2
750 | 2 || 4 || 6
752 ! 3
753 | 3 || 6 || 9
755 ! 4
756 | 4 || 8 || 12
758 ! 5
759 | 5 || 10 || 15
761 !! result
762 <table border="1" cellpadding="2">
763 <caption>Multiplication table
764 </caption>
765 <tr>
766 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
767 </th></tr>
768 <tr>
769 <th> 1
770 </th><td> 1 </td><td> 2 </td><td> 3
771 </td></tr>
772 <tr>
773 <th> 2
774 </th><td> 2 </td><td> 4 </td><td> 6
775 </td></tr>
776 <tr>
777 <th> 3
778 </th><td> 3 </td><td> 6 </td><td> 9
779 </td></tr>
780 <tr>
781 <th> 4
782 </th><td> 4 </td><td> 8 </td><td> 12
783 </td></tr>
784 <tr>
785 <th> 5
786 </th><td> 5 </td><td> 10 </td><td> 15
787 </td></tr></table>
789 !! end
791 !! test
792 Table rowspan
793 !! input
794 {| align=right border=1
795 | Cell 1, row 1 
796 |rowspan=2| Cell 2, row 1 (and 2) 
797 | Cell 3, row 1 
798 |- 
799 | Cell 1, row 2 
800 | Cell 3, row 2 
802 !! result
803 <table align="right" border="1">
804 <tr>
805 <td> Cell 1, row 1
806 </td><td rowspan="2"> Cell 2, row 1 (and 2)
807 </td><td> Cell 3, row 1
808 </td></tr>
809 <tr>
810 <td> Cell 1, row 2
811 </td><td> Cell 3, row 2
812 </td></tr></table>
814 !! end
816 !! test
817 Nested table
818 !! input
819 {| border=1
820 | &alpha;
822 {| bgcolor=#ABCDEF border=2
823 |nested
825 |table
827 |the original table again
829 !! result
830 <table border="1">
831 <tr>
832 <td> &alpha;
833 </td><td>
834 <table bgcolor="#ABCDEF" border="2">
835 <tr>
836 <td>nested
837 </td></tr>
838 <tr>
839 <td>table
840 </td></tr></table>
841 </td><td>the original table again
842 </td></tr></table>
844 !! end
846 !! test
847 Invalid attributes in table cell (bug 1830)
848 !! input
850 |Cell:|broken
852 !! result
853 <table>
854 <tr>
855 <td>broken
856 </td></tr></table>
858 !! end
862 ### Internal links
864 !! test
865 Plain link, capitalized
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 Plain link, uncapitalized
875 !! input
876 [[main Page]]
877 !! result
878 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
879 </p>
880 !! end
882 !! test
883 Piped link
884 !! input
885 [[Main Page|The Main Page]]
886 !! result
887 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
888 </p>
889 !! end
891 !! test
892 Broken link
893 !! input
894 [[Zigzagzogzagzig]]
895 !! result
896 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
897 </p>
898 !! end
900 !! test
901 Link with prefix
902 !! input
903 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
904 !! result
905 <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>
906 </p>
907 !! end
909 !! test
910 Link with suffix
911 !! input
912 [[Main Page]]xxx, [[Main Page]]XXX
913 !! result
914 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
915 </p>
916 !! end
918 !! test
919 Link with 3 brackets
920 !! input
921 [[[main page]]]
922 !! result
923 <p>[[[main page]]]
924 </p>
925 !! end
927 !! test
928 Piped link with 3 brackets
929 !! input
930 [[[main page|the main page]]]
931 !! result
932 <p>[[[main page|the main page]]]
933 </p>
934 !! end
936 !! test
937 Link with multiple pipes
938 !! input
939 [[Main Page|The|Main|Page]]
940 !! result
941 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
942 </p>
943 !! end
945 !! test
946 Link to namespaces
947 !! input
948 [[Talk:Parser testing]], [[Meta:Disclaimers]]
949 !! result
950 <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>
951 </p>
952 !! end
954 !! test
955 Piped link to namespace
956 !! input
957 [[Meta:Disclaimers|The disclaimers]]
958 !! result
959 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
960 </p>
961 !! end
963 !! test
964 Link containing }
965 !! input
966 [[Usually caused by a typo (oops}]]
967 !! result
968 <p>[[Usually caused by a typo (oops}]]
969 </p>
970 !! end
972 !! test
973 Link containing % (not as a hex sequence)
974 !! input
975 [[7% 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 single hex sequence interpreted to char
983 !! input
984 [[7%25 Solution]]
985 !! result
986 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
987 </p>
988 !!end
990 !! test
991 Link containing % as a double hex sequence interpreted to hex sequence
992 !! input
993 [[7%2525 Solution]]
994 !! result
995 <p>[[7%2525 Solution]]
996 </p>
997 !!end
999 !! test
1000 Plain link to URL
1001 !! input
1002 [[http://www.example.org]]
1003 !! result
1004 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1005 </p>
1006 !! end
1008 # I'm fairly sure the expected result here is wrong.
1009 # We want these to be URL links, not pseudo-pages with URLs for titles....
1010 # However the current output is also pretty screwy.
1012 # ----
1013 # I'm changing it to match the current output--it arguably makes more
1014 # sense in the light of the test above. Old expected result was:
1015 #<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>
1016 #</p>
1017 # But I think this test is bordering on "garbage in, garbage out" anyway.
1018 # -- wtm
1019 !! test
1020 Piped link to URL
1021 !! input
1022 Piped link to URL: [[http://www.example.org|an example URL]]
1023 !! result
1024 <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>]
1025 </p>
1026 !! end
1028 !! test
1029 BUG 2: [[page|http://url/]] should link to page, not http://url/
1030 !! input
1031 [[Main Page|http://url/]]
1032 !! result
1033 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1034 </p>
1035 !! end
1037 !! test
1038 BUG 337: Escaped self-links should be bold
1039 !! options
1040 title=[[Bug462]]
1041 !! input
1042 [[Bu&#103;462]] [[Bug462]]
1043 !! result
1044 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1045 </p>
1046 !! end
1048 !! test
1049 Self-link to section should not be bold
1050 !! options
1051 title=[[Main Page]]
1052 !! input
1053 [[Main Page#section]]
1054 !! result
1055 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1056 </p>
1057 !! end
1059 !! test
1060 <nowiki> inside a link
1061 !! input
1062 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1063 !! result
1064 <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>
1065 </p>
1066 !! end
1069 ### Interwiki links (see maintenance/interwiki.sql)
1072 !! test
1073 Inline interwiki link
1074 !! input
1075 [[MeatBall:SoftSecurity]]
1076 !! result
1077 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity</a>
1078 </p>
1079 !! end
1081 !! test
1082 Inline interwiki link with empty title (bug 2372)
1083 !! input
1084 [[MeatBall:]]
1085 !! result
1086 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="MeatBall:">MeatBall:</a>
1087 </p>
1088 !! end
1090 !! test
1091 Interwiki link encoding conversion (bug 1636)
1092 !! input
1093 *[[Wikipedia:ro:Olteni&#0355;a]]
1094 *[[Wikipedia:ro:Olteni&#355;a]]
1095 !! result
1096 <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>
1097 </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>
1098 </li></ul>
1100 !! end
1102 !! test
1103 Interwiki link with fragment (bug 2130)
1104 !! input
1105 [[MeatBall:SoftSecurity#foo]]
1106 !! result
1107 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1108 </p>
1109 !! end
1112 ## XHTML tidiness
1115 !! test
1116 <br> to <br />
1117 !! input
1118 1<br>2<br />3
1119 !! result
1120 <p>1<br />2<br />3
1121 </p>
1122 !! end
1124 !! test
1125 Incorrecly removing closing slashes from correctly formed XHTML
1126 !! input
1127 <br style="clear:both;" />
1128 !! result
1129 <p><br style="clear:both;" />
1130 </p>
1131 !! end
1133 !! test 
1134 Failing to transform badly formed HTML into correct XHTML
1135 !! input
1136 <br clear=left>
1137 <br clear=right>
1138 <br clear=all>
1139 !! result
1140 <p><br style="clear:left;" />
1141 <br style="clear:right;" />
1142 <br style="clear:both;" />
1143 </p>
1144 !!end
1146 !! test 
1147 Horizontal ruler (should it add that extra space?)
1148 !! input 
1149 <hr>
1150 <hr >
1151 foo <hr
1152 > bar
1153 !! result 
1154 <hr />
1155 <hr />
1156 foo <hr /> bar
1157 !! end
1160 ### Block-level elements
1162 !! test
1163 Common list
1164 !! input
1165 *Common list
1166 * item 2
1167 *item 3
1168 !! result
1169 <ul><li>Common list
1170 </li><li> item 2
1171 </li><li>item 3
1172 </li></ul>
1174 !! end
1176 !! test
1177 Numbered list
1178 !! input
1179 #Numbered list
1180 #item 2
1181 # item 3
1182 !! result
1183 <ol><li>Numbered list
1184 </li><li>item 2
1185 </li><li> item 3
1186 </li></ol>
1188 !! end
1190 !! test
1191 Mixed list
1192 !! input
1193 *Mixed list
1194 *# with numbers
1195 ** and bullets
1196 *# and numbers
1197 *bullets again
1198 **bullet level 2
1199 ***bullet level 3
1200 ***#Number on level 4
1201 **bullet level 2
1202 **#Number on level 3
1203 **#Number on level 3
1204 *#number level 2
1205 *Level 1
1206 !! result
1207 <ul><li>Mixed list
1208 <ol><li> with numbers
1209 </li></ol>
1210 <ul><li> and bullets
1211 </li></ul>
1212 <ol><li> and numbers
1213 </li></ol>
1214 </li><li>bullets again
1215 <ul><li>bullet level 2
1216 <ul><li>bullet level 3
1217 <ol><li>Number on level 4
1218 </li></ol>
1219 </li></ul>
1220 </li><li>bullet level 2
1221 <ol><li>Number on level 3
1222 </li><li>Number on level 3
1223 </li></ol>
1224 </li></ul>
1225 <ol><li>number level 2
1226 </li></ol>
1227 </li><li>Level 1
1228 </li></ul>
1230 !! end
1232 !! test
1233 List items are not parsed correctly following a <pre> block (bug 785)
1234 !! input
1235 * <pre>foo</pre>
1236 * <pre>bar</pre>
1237 * zar
1238 !! result
1239 <ul><li> <pre>foo</pre>
1240 </li><li> <pre>bar</pre>
1241 </li><li> zar
1242 </li></ul>
1244 !! end
1247 ### Magic variables
1249 !! test
1250 Magic variables
1251 !! input
1252 {{SITENAME}}
1253 !! result
1254 <p>MediaWiki
1255 </p>
1256 !! end
1259 ### Magic links
1261 !! test
1262 Magic links: internal link to RFC (bug 479)
1263 !! input
1264 [[RFC 123]]
1265 !! result
1266 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1267 </p>
1268 !! end
1270 !! test
1271 Magic links: RFC (bug 479)
1272 !! input
1273 RFC 822
1274 !! result
1275 <p><a href='http://www.faqs.org/rfcs/rfc822.html' class='external' title="http://www.faqs.org/rfcs/rfc822.html">RFC 822</a>
1276 </p>
1277 !! end
1279 !! test
1280 Magic links: ISBN (bug 1937)
1281 !! input
1282 ISBN 0-306-40615-2
1283 !! result
1284 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1285 </p>
1286 !! end
1288 !! test
1289 Magic links: PMID incorrectly converts space to underscore
1290 !! input
1291 PMID 1234
1292 !! result
1293 <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>
1294 </p>
1295 !! end
1298 ### Templates
1299 ####
1301 !! test
1302 Nonexistant template
1303 !! input
1304 {{thistemplatedoesnotexist}}
1305 !! result
1306 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1307 </p>
1308 !! end
1310 !! article
1311 Template:test
1312 !! text
1313 This is a test template
1314 !! endarticle
1316 !! test
1317 Simple template
1318 !! input
1319 {{test}}
1320 !! result
1321 <p>This is a test template
1322 </p>
1323 !! end
1325 !! test
1326 Template with explicit namespace
1327 !! input
1328 {{Template:test}}
1329 !! result
1330 <p>This is a test template
1331 </p>
1332 !! end
1335 !! article
1336 Template:paramtest
1337 !! text
1338 This is a test template with parameter {{{param}}}
1339 !! endarticle
1341 !! test
1342 Template parameter
1343 !! input
1344 {{paramtest|param=foo}}
1345 !! result
1346 <p>This is a test template with parameter foo
1347 </p>
1348 !! end
1350 !! article
1351 Template:paramtestnum
1352 !! text
1353 [[{{{1}}}|{{{2}}}]]
1354 !! endarticle
1356 !! test
1357 Template unnamed parameter
1358 !! input
1359 {{paramtestnum|Main Page|the main page}}
1360 !! result
1361 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1362 </p>
1363 !! end
1365 !! test
1366 BUG 553: link with two variables in a piped link
1367 !! input
1368 {| 
1369 |[[{{{1}}}|{{{2}}}]]
1371 !! result
1372 <table>
1373 <tr>
1374 <td>[[{{{1}}}|{{{2}}}]]
1375 </td></tr></table>
1377 !! end
1379 !! test
1380 Magic variable as template parameter
1381 !! input
1382 {{paramtest|param={{SITENAME}}}}
1383 !! result
1384 <p>This is a test template with parameter MediaWiki
1385 </p>
1386 !! end
1388 !! article
1389 Template:linktest
1390 !! text
1391 [[{{{param}}}|link]]
1392 !! endarticle
1394 !! test
1395 Template parameter as link source
1396 !! input
1397 {{linktest|param=Main Page}}
1398 !! result
1399 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1400 </p>
1401 !! end
1404 !!article
1405 Template:paramtest2
1406 !! text
1407 including another template, {{paramtest|param={{{arg}}}}}
1408 !! endarticle
1410 !! test
1411 Template passing argument to another template
1412 !! input
1413 {{paramtest2|arg='hmm'}}
1414 !! result
1415 <p>including another template, This is a test template with parameter 'hmm'
1416 </p>
1417 !! end
1419 !! article
1420 Template:Linktest2
1421 !! text
1422 Main Page
1423 !! endarticle
1425 !! test
1426 Template as link source
1427 !! input
1428 [[{{linktest2}}]]
1429 !! result
1430 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1431 </p>
1432 !! end
1435 !! article
1436 Template:loop1
1437 !! text
1438 {{loop2}}
1439 !! endarticle
1441 !! article
1442 Template:loop2
1443 !! text
1444 {{loop1}}
1445 !! endarticle
1447 !! test
1448 Template infinite loop
1449 !! input
1450 {{loop1}}
1451 !! result
1452 <p>{{loop1}}<!-- WARNING: template loop detected -->
1453 </p>
1454 !! end
1456 !! test
1457 Template from main namespace
1458 !! input
1459 {{:Main Page}}
1460 !! result
1461 <p>blah blah
1462 </p>
1463 !! end
1465 !! article
1466 Template:table
1467 !! text
1468 {| 
1469 | 1 || 2
1470 |- 
1471 | 3 || 4
1473 !! endarticle
1475 !! test
1476 BUG 529: Template with table, not included at beginning of line
1477 !! input
1478 foo {{table}}
1479 !! result
1480 <p>foo 
1481 </p>
1482 <table>
1483 <tr>
1484 <td> 1 </td><td> 2
1485 </td></tr>
1486 <tr>
1487 <td> 3 </td><td> 4
1488 </td></tr></table>
1490 !! end
1492 !! test
1493 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1494 !! input
1496 {{table}}
1497 !! result
1498 <p>foo
1499 </p>
1500 <table>
1501 <tr>
1502 <td> 1 </td><td> 2
1503 </td></tr>
1504 <tr>
1505 <td> 3 </td><td> 4
1506 </td></tr></table>
1508 !! end
1510 !! test
1511 BUG 41: Template parameters shown as broken links
1512 !! input
1513 {{{parameter}}}
1514 !! result
1515 <p>{{{parameter}}}
1516 </p>
1517 !! end
1520 !! article
1521 Template:MSGNW test
1522 !! text
1523 ''None'' of '''this''' should be 
1524 * interepreted
1525  but rather passed unmodified
1526 {{test}}
1527 !! endarticle
1529 # hmm, fix this or just deprecate msgnw and document its behavior?
1530 !! test
1531 msgnw keyword
1532 !! options
1533 disabled
1534 !! input
1535 {{msgnw:MSGNW test}}
1536 !! result
1537 <p>''None'' of '''this''' should be 
1538 * interepreted
1539  but rather passed unmodified
1540 {{test}}
1541 </p>
1542 !! end
1544 !! test
1545 int keyword
1546 !! input
1547 {{int:newmessages|lots of money}}
1548 !! result
1549 <p>You have lots of money.
1550 </p>
1551 !! end
1554 ### Pre-save transform tests
1556 !! test
1557 pre-save transform: subst:
1558 !! options
1560 !! input
1561 {{subst:test}}
1562 !! result
1563 This is a test template
1564 !! end
1566 !! test
1567 pre-save transform: normal template
1568 !! options
1570 !! input
1571 {{test}}
1572 !! result
1573 {{test}}
1574 !! end
1576 !! test
1577 pre-save transform: nonexistant template
1578 !! options
1580 !! input
1581 {{thistemplatedoesnotexist}}
1582 !! result
1583 {{thistemplatedoesnotexist}}
1584 !! end
1587 !! test
1588 pre-save transform: subst magic variables
1589 !! options
1591 !! input
1592 {{subst:SITENAME}}
1593 !! result
1594 MediaWiki
1595 !! end
1597 # This is bug 89, which I fixed. -- wtm
1598 !! test
1599 pre-save transform: subst: templates with parameters
1600 !! options
1602 !! input
1603 {{subst:paramtest|param="something else"}}
1604 !! result
1605 This is a test template with parameter "something else"
1606 !! end
1609 !! article
1610 Template:nowikitest
1611 !! text
1612 <nowiki>'''not wiki'''</nowiki>
1613 !! endarticle
1615 !! test
1616 pre-save transform: nowiki in subst (bug 1188)
1617 !! options
1619 !! input
1620 {{subst:nowikitest}}
1621 !! result
1622 <nowiki>'''not wiki'''</nowiki>
1623 !! end
1626 !! article
1627 Template:commenttest
1628 !! text
1629 This template has <!-- a comment --> in it.
1630 !! endarticle
1632 !! test
1633 pre-save transform: comment in subst (bug 1936)
1634 !! options
1636 !! input
1637 {{subst:commenttest}}
1638 !! result
1639 This template has <!-- a comment --> in it.
1640 !! end
1643 !! article
1644 Template:dangerous
1645 !!text
1646 <span onmouseover="alert('crap')">Oh no</span>
1647 !!endarticle
1649 !!test
1650 (confirming safety of fix for subst bug 1936)
1651 !! input
1652 {{Template:dangerous}}
1653 !! result
1654 <p><span>Oh no</span>
1655 </p>
1656 !! end
1660 ### Message transform tests
1662 !! test
1663 message transform: magic variables
1664 !! options
1666 !! input
1667 {{SITENAME}}
1668 !! result
1669 MediaWiki
1670 !! end
1672 !! test
1673 message transform: should not transform wiki markup
1674 !! options
1676 !! input
1677 ''test''
1678 !! result
1679 ''test''
1680 !! end
1683 ### Images
1685 !! test
1686 Simple image
1687 !! input
1688 [[Image:foobar.jpg]]
1689 !! result
1690 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1691 </p>
1692 !! end
1694 !! test
1695 Right-aligned image
1696 !! input
1697 [[Image:foobar.jpg|right]]
1698 !! result
1699 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="/images/3/3a/Foobar.jpg" alt="" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1701 !! end
1703 !! test
1704 Image with caption
1705 !! input
1706 [[Image:foobar.jpg|right|Caption text]]
1707 !! result
1708 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1710 !! end
1712 !! test
1713 Image with frame and link
1714 !! input
1715 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1716 !! result
1717 <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>
1719 !! end
1721 !! test
1722 Link to image page
1723 !! input
1724 [[:Image:test]]
1725 !! result
1726 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1727 </p>
1728 !! end
1730 !! test
1731 Frameless image caption with a free URL
1732 !! input
1733 [[Image:foobar.jpg|http://example.com]]
1734 !! result
1735 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="/images/3/3a/Foobar.jpg" alt="http://example.com" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1736 </p>
1737 !! end
1739 !! test
1740 Thumbnail image caption with a free URL
1741 !! input
1742 [[Image:foobar.jpg|thumb|http://example.com]]
1743 !! result
1744 <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>
1746 !! end
1748 !! test
1749 BUG 1887: A ISBN with a thumbnail
1750 !! input
1751 [[Image:foobar.jpg|thumb|ISBN 12354]]
1752 !! result
1753 <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>
1754 !! end
1756 !! test
1757 BUG 1887: A <math> with a thumbnail
1758 !! input
1759 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
1760 !! result
1761 <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>
1762 !! end
1764 # Pending resolution to bug 368
1765 !! test
1766 BUG 648: Frameless image caption with a link
1767 !! input
1768 [[Image:foobar.jpg|text with a [[link]] in it]]
1769 !! result
1770 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1771 </p>
1772 !! end
1774 !! test
1775 BUG 648: Frameless image caption with a link (suffix)
1776 !! input
1777 [[Image:foobar.jpg|text with a [[link]]foo in it]]
1778 !! result
1779 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1780 </p>
1781 !! end
1783 !! test
1784 BUG 648: Frameless image caption with an interwiki link
1785 !! input
1786 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
1787 !! result
1788 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1789 </p>
1790 !! end
1792 !! test
1793 BUG 648: Frameless image caption with a piped interwiki link
1794 !! input
1795 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
1796 !! result
1797 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1798 </p>
1799 !! end
1801 !! test
1802 Escape HTML special chars in image alt text
1803 !! input
1804 [[Image:foobar.jpg|& < > "]]
1805 !! result
1806 <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;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1807 </p>
1808 !! end
1810 !! test
1811 BUG 499: Alt text should have &#1234;, not &amp;1234;
1812 !! input
1813 [[Image:foobar.jpg|&#9792;]]
1814 !! result
1815 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="/images/3/3a/Foobar.jpg" alt="&#9792;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1816 </p>
1817 !! end
1819 !! test
1820 Broken image caption with link
1821 !! input
1822 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
1823 !! result
1824 <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.
1825 </p>
1826 !! end
1828 !! test
1829 Image caption containing another image
1830 !! input
1831 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
1832 !! result
1833 <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>
1835 !! end
1837 !! test
1838 Image caption containing a newline
1839 !! input
1840 [[Image:Foobar.jpg|This
1841 *is some text]]
1842 !! result
1843 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1844 </p>
1845 !!end
1850 ### Subpages
1852 !! article
1853 Subpage test/subpage
1854 !! text
1856 !! endarticle
1858 !! test
1859 Subpage link
1860 !! options
1861 subpage title=[[Subpage test]]
1862 !! input
1863 [[/subpage]]
1864 !! result
1865 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1866 </p>
1867 !! end
1869 !! test
1870 Subpage noslash link
1871 !! options
1872 subpage title=[[Subpage test]]
1873 !!input
1874 [[/subpage/]]
1875 !! result
1876 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1877 </p>
1878 !! end
1880 !! test
1881 Disabled subpages
1882 !! input
1883 [[/subpage]]
1884 !! result
1885 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1886 </p>
1887 !! end
1889 !! test
1890 BUG 561: {{/Subpage}}
1891 !! options
1892 subpage title=[[Page]]
1893 !! input
1894 {{/Subpage}}
1895 !! result
1896 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1897 </p>
1898 !! end
1901 ### Categories
1903 !! article
1904 Category:MediaWiki User's Guide
1905 !! text
1906 blah
1907 !! endarticle
1909 !! test
1910 Link to category
1911 !! input
1912 [[:Category:MediaWiki User's Guide]]
1913 !! result
1914 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1915 </p>
1916 !! end
1918 !! test
1919 Simple category
1920 !! options
1922 !! input
1923 [[Category: MediaWiki User's Guide]]
1924 !! result
1925 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1926 !! end
1929 ### Inter-language links
1931 !! test
1932 Inter-language links
1933 !! options
1935 !! input
1936 [[es:Alimento]]
1937 [[fr:Nourriture]]
1938 [[zh:&#39135;&#21697;]]
1939 !! result
1940 es:Alimento fr:Nourriture zh:食品
1941 !! end
1944 ### Sections
1946 !! test
1947 Basic section headings
1948 !! options
1949 title=[[Parser test script]]
1950 !! input
1951 == Headline 1 ==
1952 Some text
1954 ==Headline 2==
1955 More
1956 ===Smaller headline===
1957 Blah blah
1958 !! result
1959 <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>
1960 <p>Some text
1961 </p>
1962 <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>
1963 <p>More
1964 </p>
1965 <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>
1966 <p>Blah blah
1967 </p>
1968 !! end
1970 !! test
1971 Section headings with TOC
1972 !! options
1973 title=[[Parser test script]]
1974 !! input
1975 == Headline 1 ==
1976 === Subheadline 1 ===
1977 ===== Skipping a level =====
1978 ====== Skipping a level ======
1980 == Headline 2 ==
1981 Some text
1982 ===Another headline===
1983 !! result
1984 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Table of contents</h2></div>
1985 <ul>
1986 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
1987 <ul>
1988 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
1989 <ul>
1990 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
1991 <ul>
1992 <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>
1993 </ul>
1994 </li>
1995 </ul>
1996 </li>
1997 </ul>
1998 </li>
1999 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2000 <ul>
2001 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2002 </ul>
2003 </li>
2004 </ul>
2005 </td></tr></table>
2006 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2007 <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>
2008 <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>
2009 <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>
2010 <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>
2011 <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>
2012 <p>Some text
2013 </p>
2014 <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>
2016 !! end
2018 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2019 !! test
2020 Handling of sections up to level 6 and beyond
2021 !! input 
2022 = Level 1 Heading=
2023 == Level 2 Heading==
2024 === Level 3 Heading===
2025 ==== Level 4 Heading====
2026 ===== Level 5 Heading=====
2027 ====== Level 6 Heading======
2028 ======= Level 7 Heading=======
2029 ======== Level 8 Heading========
2030 ========= Level 9 Heading=========
2031 ========== Level 10 Heading==========
2032 !! result
2033 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Table of contents</h2></div>
2034 <ul>
2035 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2036 <ul>
2037 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2038 <ul>
2039 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2040 <ul>
2041 <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>
2042 <ul>
2043 <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>
2044 <ul>
2045 <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>
2046 <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>
2047 <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>
2048 <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>
2049 <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>
2050 </ul>
2051 </li>
2052 </ul>
2053 </li>
2054 </ul>
2055 </li>
2056 </ul>
2057 </li>
2058 </ul>
2059 </li>
2060 </ul>
2061 </td></tr></table>
2062 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2063 </p>
2064 <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>
2065 <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>
2066 <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>
2067 <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>
2068 <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>
2069 <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>
2070 <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>
2071 <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>
2072 <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>
2073 <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>
2075 !! end
2077 !! test
2078 Resolving duplicate section names
2079 !! options
2080 title=[[Parser test script]]
2081 !! input
2082 == Foo bar ==
2083 == Foo bar ==
2084 !! result
2085 <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>
2086 <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>
2088 !! end
2090 !! article
2091 Template:sections
2092 !! text
2093 ===Section 1===
2094 ==Section 2==
2095 !! endarticle
2097 !! test
2098 Template with sections, __NOTOC__
2099 !! options
2100 title=[[Parser test script]]
2101 !! input
2102 __NOTOC__
2103 ==Section 0==
2104 {{sections}}
2105 ==Section 4==
2106 !! result
2107 <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>
2108 <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>
2109 <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>
2110 <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>
2112 !! end
2114 !! test
2115 __NOEDITSECTION__ keyword
2116 !! input
2117 __NOEDITSECTION__
2118 ==Section 1==
2119 ==Section 2==
2120 !! result
2121 <a name="Section_1"></a><h2>Section 1</h2>
2122 <a name="Section_2"></a><h2>Section 2</h2>
2124 !! end
2126 !! test
2127 Link inside a section heading
2128 !! options
2129 title=[[Parser test script]]
2130 !! input
2131 ==Section with a [[Main Page|link]] in it==
2132 !! result
2133 <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>
2135 !! end
2138 !! test
2139 BUG 1219 URL next to image (good)
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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2144 </p>
2145 !!end
2147 !! test
2148 BUG 1219 URL next to image (broken)
2149 !! input
2150 http://example.com[[Image:foobar.jpg]]
2151 !! result
2152 <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" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2153 </p>
2154 !!end
2156 !! test
2157 Bug 1186 news: in the middle of text
2158 !! input
2159 http://en.wikinews.org/wiki/Wikinews:Workplace
2160 !! result
2161 <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>
2162 </p>
2163 !!end
2166 !! test
2167 Namespaced link must have a title
2168 !! input
2169 [[Project:]]
2170 !! result
2171 <p>[[Project:]]
2172 </p>
2173 !!end
2175 !! test
2176 Namespaced link must have a title (bad fragment version)
2177 !! input
2178 [[Project:#fragment]]
2179 !! result
2180 <p>[[Project:#fragment]]
2181 </p>
2182 !!end
2185 !! test
2186 div with no attributes
2187 !! input
2188 <div>HTML rocks</div>
2189 !! result
2190 <div>HTML rocks</div>
2192 !! end
2194 !! test
2195 div with double-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 single-quoted 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 unquoted attribute
2214 !! input
2215 <div id=rock>HTML rocks</div>
2216 !! result
2217 <div id="rock">HTML rocks</div>
2219 !! end
2221 !! test
2222 div with illegal double attributes
2223 !! input
2224 <div align="center" align="right">HTML rocks</div>
2225 !! result
2226 <div align="right">HTML rocks</div>
2228 !!end
2230 !! test
2231 HTML multiple attributes correction
2232 !! input
2233 <p class="error" class="awesome">Awesome!</p>
2234 !! result
2235 <p class="awesome">Awesome!</p>
2237 !!end
2239 !! test
2240 Table multiple attributes correction
2241 !! input
2243 !+ class="error" class="awesome"| status
2245 !! result
2246 <table>
2247 <tr>
2248 <th class="awesome">status</th>
2249 </tr>
2250 </table>
2252 !!end
2254 !! test
2255 DIV IN UPPERCASE
2256 !! input
2257 <DIV ALIGN="center">HTML ROCKS</DIV>
2258 !! result
2259 <div align="center">HTML ROCKS</div>
2261 !!end
2264 !! test
2265 text with amp in the middle of nowhere
2266 !! input
2267 Remember AT&T?
2268 !!result
2269 <p>Remember AT&amp;T?
2270 </p>
2271 !! end
2273 !! test
2274 text with character entity: eacute
2275 !! input
2276 I always thought &eacute; was a cute letter.
2277 !! result
2278 <p>I always thought &eacute; was a cute letter.
2279 </p>
2280 !! end
2282 !! test
2283 text with undefined character entity: xacute
2284 !! input
2285 I always thought &xacute; was a cute letter.
2286 !! result
2287 <p>I always thought &amp;xacute; was a cute letter.
2288 </p>
2289 !! end
2293 ### Media links
2296 !! test
2297 Media link
2298 !! input
2299 [[Media:Foobar.jpg]]
2300 !! result
2301 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2302 </p>
2303 !! end
2305 !! test
2306 Media link with text
2307 !! input
2308 [[Media:Foobar.jpg|A neat file to look at]]
2309 !! result
2310 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2311 </p>
2312 !! end
2314 # FIXME: this is still bad HTML tag nesting
2315 !! test
2316 Media link with nasty text
2317 !! input
2318 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2319 !! result
2320 <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>
2321 </p>
2322 !! end
2324 !! test
2325 Media link to nonexistent file (bug 1702)
2326 !! input
2327 [[Media:No such.jpg]]
2328 !! result
2329 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2330 </p>
2331 !! end
2335 !! test
2336 Character reference normalization in link text (bug 1938)
2337 !! input
2338 [[Main Page|this&that]]
2339 !! result
2340 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2341 </p>
2342 !!end
2344 !! test
2345 Empty attribute crash test (bug 2067)
2346 !! input
2347 <font color="">foo</font>
2348 !! result
2349 <p><font color="">foo</font>
2350 </p>
2351 !! end
2353 !! test
2354 Empty attribute crash test single-quotes (bug 2067)
2355 !! input
2356 <font color=''>foo</font>
2357 !! result
2358 <p><font color="">foo</font>
2359 </p>
2360 !! end
2362 !! test
2363 Attribute test: equals, then nothing
2364 !! input
2365 <font color=>foo</font>
2366 !! result
2367 <p><font>foo</font>
2368 </p>
2369 !! end
2371 !! test
2372 Attribute test: unquoted value
2373 !! input
2374 <font color=x>foo</font>
2375 !! result
2376 <p><font color="x">foo</font>
2377 </p>
2378 !! end
2380 !! test
2381 Attribute test: unquoted but illegal value (hash)
2382 !! input
2383 <font color=#x>foo</font>
2384 !! result
2385 <p><font color="#x">foo</font>
2386 </p>
2387 !! end
2389 !! test
2390 Attribute test: no value
2391 !! input
2392 <font color>foo</font>
2393 !! result
2394 <p><font color="color">foo</font>
2395 </p>
2396 !! end
2398 !! test
2399 Bug 2095: link with three closing brackets
2400 !! input
2401 [[Main Page]]]
2402 !! result
2403 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
2404 </p>
2405 !! end
2407 !! test
2408 Bug 2095: link with pipe and three closing brackets
2409 !! input
2410 [[Main Page|link]]]
2411 !! result
2412 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
2413 </p>
2414 !! end
2418 ### Safety
2421 !! article
2422 Template:Dangerous attribute
2423 !! text
2424 " onmouseover="alert(document.cookie)
2425 !! endarticle
2427 !! article
2428 Template:Dangerous style attribute
2429 !! text
2430 border-size: expression(alert(document.cookie))
2431 !! endarticle
2433 !! article
2434 Template:Div style
2435 !! text
2436 <div style="float: right; {{{1}}}">Magic div</div>
2437 !! endarticle
2439 !! test
2440 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
2441 !! input
2442 <div title="{{test}}"></div>
2443 !! result
2444 <div title="This is a test template"></div>
2446 !! end
2448 !! test
2449 Bug 2304: HTML attribute safety (dangerous template; 2309)
2450 !! input
2451 <div title="{{dangerous attribute}}"></div>
2452 !! result
2453 <div title=""></div>
2455 !! end
2457 !! test
2458 Bug 2304: HTML attribute safety (dangerous style template; 2309)
2459 !! input
2460 <div style="{{dangerous style attribute}}"></div>
2461 !! result
2462 <div></div>
2464 !! end
2466 !! test
2467 Bug 2304: HTML attribute safety (safe parameter; 2309)
2468 !! input
2469 {{div style|width: 200px}}
2470 !! result
2471 <div style="float: right; width: 200px">Magic div</div>
2473 !! end
2475 !! test
2476 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
2477 !! input
2478 {{div style|width: expression(alert(document.cookie))}}
2479 !! result
2480 <div>Magic div</div>
2482 !! end
2484 !! test
2485 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
2486 !! input
2487 {{div style|"><script>alert(document.cookie)</script>}}
2488 !! result
2489 <div>Magic div</div>
2491 !! end
2493 !! test
2494 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
2495 !! input
2496 {{div style|" ><script>alert(document.cookie)</script>}}
2497 !! result
2498 <div style="float: right; ">Magic div</div>
2500 !! end
2502 !! test
2503 Bug 2304: HTML attribute safety (link)
2504 !! input
2505 <div title="[[Main Page]]"></div>
2506 !! result
2507 <div title="&#91;&#91;Main Page]]"></div>
2509 !! end
2511 !! test
2512 Bug 2304: HTML attribute safety (italics)
2513 !! input
2514 <div title="''foobar''"></div>
2515 !! result
2516 <div title="&#39;&#39;foobar&#39;&#39;"></div>
2518 !! end
2520 !! test
2521 Bug 2304: HTML attribute safety (bold)
2522 !! input
2523 <div title="'''foobar'''"></div>
2524 !! result
2525 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
2527 !! end
2529 !! test
2530 Bug 2304: HTML attribute safety (ISBN)
2531 !! input
2532 <div title="ISBN 1234567890"></div>
2533 !! result
2534 <div title="&#73;SBN 1234567890"></div>
2536 !! end
2538 !! test
2539 Bug 2304: HTML attribute safety (RFC)
2540 !! input
2541 <div title="RFC 1234"></div>
2542 !! result
2543 <div title="&#82;FC 1234"></div>
2545 !! end
2547 !! test
2548 Bug 2304: HTML attribute safety (PMID)
2549 !! input
2550 <div title="PMID 1234567890"></div>
2551 !! result
2552 <div title="&#80;MID 1234567890"></div>
2554 !! end
2556 !! test
2557 Bug 2304: HTML attribute safety (web link)
2558 !! input
2559 <div title="http://example.com/"></div>
2560 !! result
2561 <div title="http&#58;//example.com/"></div>
2563 !! end
2565 !! test
2566 Bug 2304: HTML attribute safety (named web link)
2567 !! input
2568 <div title="[http://example.com/ link]"></div>
2569 !! result
2570 <div title="&#91;http&#58;//example.com/ link]"></div>
2572 !! end
2575 TODO:
2576 more images
2577 more tables
2578 math
2579 character entities
2580 and much more