### This file has tests for external and url links # The parsoid-compatible option below is only relevant when we are running # parser tests in integrated mode with Parsoid. This option is ignored # when this test file is run with Parsoid in standalone mode. !! options parsoid-compatible=wt2html,wt2wt version=2 !! end !! article Template:1x !! text {{{1}}} !! endarticle !! article Wikilink !! text Dummy article to suppress redlinks in tests !! end !! article Museo Picasso (París) !! text Dummy article to suppress redlinks in tests !! end !! test External links: non-bracketed !! options extlinks !! wikitext Non-bracketed: http://example.com !! metadata extlink=http://example.com !! html
Non-bracketed: http://example.com
!! end # parsoid doesn't explicitly mark autonumbered links, see T55505 !! test External links: numbered !! wikitext Numbered: [http://example.com] Numbered: [http://example.net] Numbered: [http://example.com] !! html/phpNumbered: [1] Numbered: [2] Numbered: [3]
!! html/parsoid !!end !! test External links: specified text !! wikitext Specified text: [http://example.com link] !! htmlSpecified text: link
!!end !! test External links: trail !! wikitext Linktrails should not work for external links: [http://example.com link]s !! htmlLinktrails should not work for external links: links
!! end !! test External links: dollar sign in URL !! wikitext http://example.com/1$2345 !! html !! end # parsoid doesn't explicitly mark autonumbered links, see T55505 !! test External links: dollar sign in URL (autonumber) !! wikitext [http://example.com/1$2345] !! html/php !! html/parsoid !!end !! test External links: open square bracket forbidden in URL (T6377) !! options parsoid=wt2html,wt2wt,html2html !! wikitext http://example.com/1[2345 !! html/phphttp://example.com/1[2345
!! html/parsoidhttp://example.com/1[2345
!! end !! test External links: open square bracket forbidden in URL (named) (T6377) !! options parsoid=wt2html,html2html !! wikitext [http://example.com/1[2345] !! html/php !! html/parsoid !!end # parsoid adds a space before the link name !! test External links: open square bracket forbidden in URL (named) (T6377) Parsoid variant. !! wikitext [http://example.com/1 [2345] !! html !!end !! test External links: nowiki in URL link text (T8230) !! wikitext [http://example.com/[http://example.com/ first second]
!!end !! test External links: Pipe char between url and text !! wikitext [http://example.com | link] !! html !!end !! test External links: protocol-relative URL in brackets !! wikitext [//example.com/ Test] !! html !! end # parsoid doesn't explicitly mark autonumbered links, see T55505 !! test External links: protocol-relative URL in brackets without text !! wikitext [//example.com] !! html/php !! html/parsoid !! end !! test External links: protocol-relative URL in free text is left alone !! wikitext //example.com/Foo !! html//example.com/Foo
!!end !! test External links: protocol-relative URL in the middle of a word is left alone (T32269) !! wikitext foo//example.com/Foo !! htmlfoo//example.com/Foo
!! end ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia: !! test External links: with no contents !! options parsoid=wt2html,wt2wt !! wikitext [http://en.wikipedia.org/wiki/Foo] [[wikipedia:Foo|Bar]] [[wikipedia:Foo|Bar]] !! html/php !! html/parsoid !! end !! test External links: Free with trailing punctuation !! wikitext http://example.com, http://example.com; http://example.com\ http://example.com. http://example.com: http://example.com! http://example.com? http://example.com) http://example.com/url_with_(brackets) (http://example.com/url_without_brackets) http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity< http://example.com/url_with_entity< http://example.com/url_with_entity< !! html/phphttp://example.com, http://example.com; http://example.com\ http://example.com. http://example.com: http://example.com! http://example.com? http://example.com) http://example.com/url_with_(brackets) (http://example.com/url_without_brackets) http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity< http://example.com/url_with_entity< http://example.com/url_with_entity<
!! html/parsoidhttp://example.com, http://example.com; http://example.com\ http://example.com. http://example.com: http://example.com! http://example.com? http://example.com) http://example.com/url_with_(brackets) (http://example.com/url_without_brackets) http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity& http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity http://example.com/url_with_entity< http://example.com/url_with_entity< http://example.com/url_with_entity<
!! end !! test External links: tricky Parsoid html2html case !! options parsoid=wt2html,wt2wt,html2html !! wikitext http://example.com/url_with_entity& !! html/phphttp://example.com/url_with_entity&
!! html/parsoidhttp://example.com/url_with_entity&
!! end !! test External links: html2html with trailing dot (T263203) !! wikitext test [http://example.com/test. http://example.com/test.] test test http://example.com/test. test !! html/parsoidtest http://example.com/test. test
test http://example.com/test. test
!! html/phptest http://example.com/test. test
test http://example.com/test. test
!! end !! test External links: Free with trailing quotes (T113666) !! wikitext '''News:''' Stuff here news:'a'b''c''d e !! html/phpNews: Stuff here
news:'a'bcd e
!! html/parsoidNews: Stuff here
news:'a'bcd e
!! end !! test External links: with entity !! wikitext [http:// www.librarieswithoutborders.org Libraries without borders] !! html/php !! html/parsoid !! end !! test External links: Lone protocols are never linked (T105697) !! wikitext http:// http://; (http://) bitcoin: bitcoin:; (bitcoin:) !! htmlhttp:// http://; (http://) bitcoin: bitcoin:; (bitcoin:)
!! end !! test External links: No preceding word characters allowed (T67278) !! wikitext NOPEhttp://example.com N0http://example.com ok:http://example.com ok-http://example.com !! htmlNOPEhttp://example.com N0http://example.com ok:http://example.com ok-http://example.com
!! end !! test External links: nofollow domain exception !! wikitext A [https://no-nofollow.org/foobar link], and another [https://example.org link]. !! html !!end !! test External image !! wikitext External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! htmlExternal image:
External image from https:
External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
!! html/parsoidExternal image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
!! html/parsoid+integratedExternal image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
!! end !! test Link to non-http image, no img tag !! wikitext Link to non-http image, no img tag: ftp://example.com/test.jpg !! htmlLink to non-http image, no img tag: ftp://example.com/test.jpg
!! end !! test External links: terminating separator !! wikitext Terminating separator: http://example.com/thing, !! htmlTerminating separator: http://example.com/thing,
!! end !! test External links: intervening separator !! wikitext Intervening separator: http://example.com/1,2,3 !! htmlIntervening separator: http://example.com/1,2,3
!! end !! test External links: old bug with URL in query !! wikitext Old bug with URL in query: [http://example.com/thing?url=http://example.com link] !! htmlOld bug with URL in query: link
!! end !! test External links: old URL-in-URL bug, mixed protocols !! wikitext And again with mixed protocols: [ftp://example.com?url=http://example.com link] !! htmlAnd again with mixed protocols: link
!!end # Since Parsoid is starting to emit canonical wikitext for links, # [http://example.com http://example.com] will not RT back to that # form anymore. !! test External links: URL in text !! options parsoid=wt2html !! wikitext URL in text: [http://example.com http://example.com] !! html/phpURL in text: http://example.com
!! html/parsoidURL in text: http://example.com
!! end !! test External links: Clickable images !! wikitext ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png] !! html/php !! html/parsoid !! end !! test External links: raw ampersand !! options extlinks !! wikitext Old & use: http://x&y !! metadata extlink=http://x&y !! htmlOld & use: http://x&y
!! end !! test External links: encoded ampersand !! options extlinks !! wikitext Old & use: http://x&y !! metadata extlink=http://x&y !! html/phpOld & use: http://x&y
!! html/parsoidOld & use: http://x&y
!! end !! test External links: encoded equals (T8102) !! options extlinks !! wikitext http://example.com/?foo=bar !! metadata extlink=http://example.com/?foo=bar !! html/php !! html/parsoid !! end ## ## Note that parsoid doesn't explicit mark autonumbered links, nor ## does it number them. As discussed in T55505, we can identify ## autonumbered links via CSS. ## !! test External links: [raw ampersand] !! options extlinks !! wikitext Old & use: [http://x&y] !! metadata extlink=http://x&y !! html/phpOld & use: [1]
!! html/parsoid !! end # note that parsoid html is identical to [raw ampersand] case; so html2wt # mode will return the [raw ampersand] wikitext !! test External links: [encoded ampersand] !! options parsoid=wt2html,wt2wt,html2html extlinks !! wikitext Old & use: [http://x&y] !! metadata extlink=http://x&y !! html/phpOld & use: [1]
!! html/parsoid !! end !! test External links: [raw equals] !! options extlinks !! wikitext [http://example.com/?foo=bar] !! metadata extlink=http://example.com/?foo=bar !! html/php !! html/parsoid !! end # note that parsoid html is identical to [raw equals] case; so html2wt # mode will return the [raw equals] wikitext !! test External links: [encoded equals] (T8102) !! options parsoid=wt2html,wt2wt,html2html extlinks !! wikitext [http://example.com/?foo=bar] !! metadata extlink=http://example.com/?foo=bar !! html/php !! html/parsoid !! end # xxx parsoid strips the IDN character, so the round-trip tests will # obviously fail and are disabled. --cscott !! test External links: [IDN ignored character reference in hostname; strip it right off] !! options parsoid=wt2html,wt2wt,html2html !! wikitext [http://example.com/] !! html/php !! html/parsoid !! end # FIXME: This test (the IDN characters in the text of a link) is an inconsistency. # Where an external link could easily circumvent the sanitization of the text of # a link like this (where an IDN-ignore character is in the URL somewhere), this # test demands a higher standard. That's a bit strange. # # Example: # # http://example.com -> [http://example.com|http://example.com] # [http://example.com|http://example.com] -> [http://example.com|http://example.com] # # The first example is sanitized, but the second is not. Any security benefits # from this production are trivial to circumvent. Either remove this test and # let the parser(s) do their thing unaccosted, or fix the inconsistency and change # the test accordingly. # # All our love, # The Parsoid team. # xxx parsoid strips the IDN character, so the round-trip tests will # obviously fail and are disabled. --cscott !! test External links: IDN ignored character reference in hostname; strip it right off !! options parsoid=wt2html,html2html !! wikitext http://example.com/ !! html/php !! html/parsoid !! end !! test External links: www.jpeg.org (T2554) !! wikitext http://www.jpeg.org !! html !! end # parsoid doesn't explicitly mark autonumbered links, see T55505 !! test External links: URL within URL (T2002) !! wikitext [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp] !! html/php !! html/parsoid !! end !! test T2361: URL inside bracketed URL !! wikitext [http://www.example.com/foo http://www.example.com/bar] !! html !! end !! test T2361: URL within URL, not bracketed !! wikitext http://www.example.com/foo?=http://www.example.com/bar !! htmlhttp://www.example.com/foo?=http://www.example.com/bar
!! end !! test T2289: ">"-token in URL-tail !! wikitext http://www.example.com/http://www.example.com/<hello>
!!end !! test T2289: literal ">"-token in URL-tail !! wikitext http://www.example.com/html !! html/php !! html/parsoid !! end !! test T2289: ">"-token in bracketed URL !! wikitext [http://www.example.com/http://www.example.com/"hello"
!!end !! test T2289: literal double quote in bracketed URL !! wikitext [http://www.example.com/"hello" stuff] !! html !!end !! test External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081) !! wikitext [http://www.example.com test] !! html !! end !! test External links: link text with spaces !! wikitext [http://www.example.com a b c] [http://www.example.com ''a'' ''b''] !! html !! end # Note edge case difference between PHP and Parsoid here. !! test External links: wiki links within external link (T5695) !! options parsoid=wt2html !! wikitext [http://example.com [[wikilink]] embedded in ext link] [http://example.com test [[wikilink]] embedded in ext link] !! html/phpwikilink embedded in ext link
test wikilink embedded in ext link
!! html/parsoidwikilink embedded in ext link
test wikilink embedded in ext link
!! end !! test T2787: Links with one slash after the url protocol are invalid !! wikitext http:/example.com [http:/example.com title] !! htmlhttp:/example.com
[http:/example.com title]
!! end !! test Bracketed external links with template-generated invalid target !! wikitext [{{1x|http:/example.com}} title] !! html[http:/example.com title]
!! end !! test T6781: %26 in URL !! wikitext http://www.example.com/?title=AT%26T !! html/phphttp://www.example.com/?title=AT%26T
!! html/parsoidhttp://www.example.com/?title=AT%26T
!! end # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain # % is actually legal in HTML5. Any change in output would need testing though. !! test T6781, T7267: %25 in URL !! wikitext http://www.example.com/?title=100%25_Bran !! html/phphttp://www.example.com/?title=100%25_Bran
!! html/parsoidhttp://www.example.com/?title=100%25_Bran
!! end !! test T6781, T7267: %28, %29 in URL !! wikitext http://www.example.com/?title=Ben-Hur_%281959_film%29 !! html/phphttp://www.example.com/?title=Ben-Hur_%281959_film%29
!! html/parsoidhttp://www.example.com/?title=Ben-Hur_%281959_film%29
!! end !! test T6781: %26 in autonumber URL !! wikitext [http://www.example.com/?title=AT%26T] !! html/php !! html/parsoid !! end !! test T6781, T7267: %26 in autonumber URL !! wikitext [http://www.example.com/?title=100%25_Bran] !! html/php !! html/parsoid !! end !! test T6781, T7267: %28, %29 in autonumber URL !! wikitext [http://www.example.com/?title=Ben-Hur_%281959_film%29] !! html/php !! html/parsoid !! end !! test T6781: %26 in bracketed URL !! wikitext [http://www.example.com/?title=AT%26T link] !! html/php !! html/parsoid !! end !! test T6781, T7267: %25 in bracketed URL !! wikitext [http://www.example.com/?title=100%25_Bran link] !! html !! end !! test T6781, T7267: %28, %29 in bracketed URL !! wikitext [http://www.example.com/?title=Ben-Hur_%281959_film%29 link] !! html/php !! html/parsoid !! end !! test External link containing a period in the anchor. (T65947) !! wikitext [//foo.org/bar#baz. bang] [//foo.org/bar. bang] !! html/php !! html/parsoid !! end !! test External link containing a single quote. (T65947) !! wikitext [//foo.org/bar'baz] [//foo.org/bar'baz bang] !! html/php !! html/parsoid !! end !! test External link containing double-single-quotes in text '' (T6598 check) !! wikitext Some [http://example.com/ pretty ''italics'' and stuff]! !! htmlSome pretty italics and stuff!
!! end # Note different rendering by Parsoid here compared to the legacy parser. !! test External link containing double-single-quotes in text embedded in italics (T6598 check) !! wikitext ''Some [http://example.com/ pretty ''italics'' and stuff]!'' !! html/phpSome pretty italics and stuff!
!! html/parsoidSome pretty italics and stuff!
!! end # Don't add the html/php section since the output is broken and there isn't any reason to spec it !! test External link containing double-single-quotes with no space separating the url from text in italics !! wikitext [http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].] !! html/phpLa muerte de Casagemas (1901) en el sitio de Museo Picasso.
!! html/parsoidLa muerte de Casagemas (1901) en el sitio de Museo Picasso.
!! end !! test External link with comments in link text !! wikitext [http://www.google.com Google ] !! html/php !! html/parsoid !! end !! test External link to bare IPv4 address !! wikitext [http://192.168.0.1 Link] !! html/php !! html/parsoid !! end !! test URL-encoding in URL functions (single parameter) !! wikitext {{localurl:Some page|amp=&}} !! html/index.php?title=Some_page&=&
!! end !! test URL-encoding in URL functions (multiple parameters) !! wikitext {{localurl:Some page|q=?&=&}} !! html/index.php?title=Some_page&q=?&=&
!! end !! test Brackets in urls !! wikitext http://example.com/index.php?foozoid%5B%5D=bar http://example.com/index.php?foozoid[]=bar !! html/phphttp://example.com/index.php?foozoid%5B%5D=bar
http://example.com/index.php?foozoid%5B%5D=bar
!! html/parsoidhttp://example.com/index.php?foozoid%5B%5D=bar
http://example.com/index.php?foozoid%5B%5D=bar
!! end !! test IPv6 urls, autolink format (T23261) !! wikitext http://[2404:130:0:1000::187:2]/index.php Examples from RFC 2373, section 2.2: *http://[1080::8:800:200C:417A]/unicast *http://[FF01::101]/multicast *http://[::1]/loopback *http://[::]/unspecified *http://[::13.1.68.3]/ipv4compat *http://[::FFFF:129.144.52.38]/ipv4compat Examples from RFC 2732, section 2: *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html *http://[1080:0:0:0:8:800:200C:417A]/index.html *http://[3ffe:2a00:100:7031::1] *http://[1080::8:800:200C:417A]/foo *http://[::192.9.5.5]/ipng *http://[::FFFF:129.144.52.38]:80/index.html *http://[2010:836B:4179::836B:4179] !! html/phphttp://[2404:130:0:1000::187:2]/index.php
Examples from RFC 2373, section 2.2:
Examples from RFC 2732, section 2:
http://[2404:130:0:1000::187:2]/index.php
Examples from RFC 2373, section 2.2:
Examples from RFC 2732, section 2:
größhttps://foo.org
größ https://foo.org
아들 고건 사진https://foo.org
!! html/parsoidgrößhttps://foo.org
größ https://foo.org
아들 고건 사진https://foo.org
!! end !! test IPv6 urls, bracketed format (T23261) !! wikitext [http://[2404:130:0:1000::187:2]/index.php test] Examples from RFC 2373, section 2.2: *[http://[1080::8:800:200C:417A] unicast] *[http://[FF01::101] multicast] *[http://[::1]/ loopback] *[http://[::] unspecified] *[http://[::13.1.68.3] ipv4compat] *[http://[::FFFF:129.144.52.38] ipv4compat] Examples from RFC 2732, section 2: *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1] *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2] *[http://[3ffe:2a00:100:7031::1] 3] *[http://[1080::8:800:200C:417A]/foo 4] *[http://[::192.9.5.5]/ipng 5] *[http://[::FFFF:129.144.52.38]:80/index.html 6] *[http://[2010:836B:4179::836B:4179] 7] !! html/phpExamples from RFC 2373, section 2.2:
Examples from RFC 2732, section 2:
!! html/parsoidExamples from RFC 2373, section 2.2:
Examples from RFC 2732, section 2:
!! end !! test Non-extlinks in brackets !! wikitext [foo] [foo bar] [foo ''bar''] [fool's] errand [fool's errand] [{{1x|foo}}] [{{1x|foo}} bar] [{{1x|foo}} ''bar''] [{{1x|foo}}l's] errand [{{1x|foo}}l's errand] [url={{1x|foo}}] [url=http://example.com] [http:// bare protocols don't count] !! html/php[foo] [foo bar] [foo bar] [fool's] errand [fool's errand] [foo] [foo bar] [foo bar] [fool's] errand [fool's errand] [url=foo] [url=http://example.com] [http:// bare protocols don't count]
!! html/parsoid[foo] [foo bar] [foo bar] [fool's] errand [fool's errand] [foo] [foo bar] [foo bar] [fool's] errand [fool's errand] [url=foo] [url=http://example.com] [http:// bare protocols don't count]
!! end !! test Percent encoding in external links !! wikitext [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search] !! html/php !! html/parsoid !! end !! test Use url link syntax for links where the content is equal the link target !! wikitext http://example.com !! html/php !! html/parsoid !! end !! test Parenthesis in external links, especially URL links !! wikitext http://example.com) http://example.com/test) http://example.com/(test) http://example.com/((test) (http://example.com/(test)) (http://example.com/(test))))) http://example.com/a)b [http://example.com) foo] !! html/php(http://example.com/(test)))))
!! html/parsoid(http://example.com/(test)))))
!! end !! test Parenthesis in external links, w/ transclusion or comment !! wikitext (http://example.com/{{1x|hi}}) (http://example.com) !! html/php !! html/parsoid !! end ### Parsoid-specific tests !! test mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723) !! options parsoid=wt2wt !! wikitext [http://en.wikipedia.org/wiki/European_Robin European Robin] !! html/parsoid THIS SECTION IS NOT USED (but Parsoid won't run the test without it) !! end !! test Parsoid extlink with _blank target !! options externallinktarget=_blank !! wikitext [https://www.example.com] !! html/parsoid !! html/php !! end !! test Parsoid extlink with _self target !! options externallinktarget=_self !! wikitext [https://www.example.com] !! html/parsoid !! html/php !! end !! test Extlink in square brackets with entity !! wikitext [ [http://test.com 123] ] [http://test.com [123] !! html/php[ 123 ]
!! html/parsoid[ 123 ]
!! end !! test Extlink in indent pre gets link attributes !! wikitext [http://test.com 123] !! html/php123!! html/parsoid
123!! end