### 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 !! wikitext Non-bracketed: 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/php

Numbered: [1] Numbered: [2] Numbered: [3]

!! html/parsoid

Numbered: Numbered: Numbered:

!!end !! test External links: specified text !! wikitext Specified text: [http://example.com link] !! html

Specified text: link

!!end !! test External links: trail !! wikitext Linktrails should not work for external links: [http://example.com link]s !! html

Linktrails should not work for external links: links

!! end !! test External links: dollar sign in URL !! wikitext http://example.com/1$2345 !! html

http://example.com/1$2345

!! 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

[1]

!! 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/php

http://example.com/1[2345

!! html/parsoid

http://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

[2345

!! html/parsoid

[2345

!!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

[2345

!!end !! test External links: nowiki in URL link text (T8230) !! wikitext [http://example.com/ ''example site''] !! html

''example site''

!! end !! test External links: newline forbidden in text (T8230 regression check) !! wikitext [http://example.com/ first second] !! html

[http://example.com/ first second]

!!end !! test External links: Pipe char between url and text !! wikitext [http://example.com | link] !! html

| link

!!end !! test External links: protocol-relative URL in brackets !! wikitext [//example.com/ Test] !! html

Test

!! 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

[1]

!! 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 !! html

foo//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

[1]

Bar

Bar

!! html/parsoid

Bar

Bar

!! 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/php

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/parsoid

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<

!! end !! test External links: tricky Parsoid html2html case !! options parsoid=wt2html,wt2wt,html2html !! wikitext http://example.com/url_with_entity&amp; !! html/php

http://example.com/url_with_entity&amp;

!! html/parsoid

http://example.com/url_with_entity&amp;

!! 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/parsoid

test http://example.com/test. test

test http://example.com/test. test

!! html/php

test 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/php

News: Stuff here

news:'a'bcd e

!! html/parsoid

News: Stuff here

news:'a'bcd e

!! end !! test External links: with entity !! wikitext [http:// www.librarieswithoutborders.org Libraries without borders] !! html/php

Libraries without borders

!! html/parsoid

Libraries without borders

!! end !! test External links: Lone protocols are never linked (T105697) !! wikitext http:// http://; (http://) bitcoin: bitcoin:; (bitcoin:) !! html

http:// 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 !! html

NOPEhttp://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

A link, and another link.

!!end !! test External image !! wikitext External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! html

External image: Ncwikicol.png

!! end !! test External image from https !! wikitext External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! html

External image from https: Ncwikicol.png

!! end !! test External image (when not allowed) !! options wgAllowExternalImages=0 !! wikitext External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! html/php

External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png

!! html/parsoid

External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png

!! html/parsoid+integrated

External 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 !! html

Link 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, !! html

Terminating separator: http://example.com/thing,

!! end !! test External links: intervening separator !! wikitext Intervening separator: http://example.com/1,2,3 !! html

Intervening 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] !! html

Old 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] !! html

And 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/php

URL in text: http://example.com

!! html/parsoid

URL 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

ja-style clickable images: Ncwikicol.png

!! html/parsoid

ja-style clickable images: Ncwikicol.png

!! end !! test External links: raw ampersand !! wikitext Old & use: http://x&y !! html

Old & use: http://x&y

!! end !! test External links: encoded ampersand !! wikitext Old & use: http://x&y !! html/php

Old & use: http://x&y

!! html/parsoid

Old & use: http://x&y

!! end !! test External links: encoded equals (T8102) !! wikitext http://example.com/?foo=bar !! html/php

http://example.com/?foo=bar

!! html/parsoid

http://example.com/?foo=bar

!! 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] !! wikitext Old & use: [http://x&y] !! html/php

Old & use: [1]

!! html/parsoid

Old & use:

!! 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 !! wikitext Old & use: [http://x&y] !! html/php

Old & use: [1]

!! html/parsoid

Old & use:

!! end !! test External links: [raw equals] !! wikitext [http://example.com/?foo=bar] !! html/php

[1]

!! 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 !! wikitext [http://example.com/?foo=bar] !! html/php

[1]

!! 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://e‌xample.com/] !! html/php

[1]

!! 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://e‌xample.com -> [http://example.com|http://example.com] # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.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://e‌xample.com/ !! html/php

http://example.com/

!! html/parsoid

http://example.com/

!! end !! test External links: www.jpeg.org (T2554) !! wikitext http://www.jpeg.org !! html

http://www.jpeg.org

!! 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

[1]

!! html/parsoid

!! end !! test T2361: URL inside bracketed URL !! wikitext [http://www.example.com/foo http://www.example.com/bar] !! html

http://www.example.com/bar

!! end !! test T2361: URL within URL, not bracketed !! wikitext http://www.example.com/foo?=http://www.example.com/bar !! html

http://www.example.com/foo?=http://www.example.com/bar

!! end !! test T2289: ">"-token in URL-tail !! wikitext http://www.example.com/ !! html

http://www.example.com/<hello>

!!end !! test T2289: literal ">"-token in URL-tail !! wikitext http://www.example.com/html !! html/php

http://www.example.com/html

!! html/parsoid

http://www.example.com/html

!! end !! test T2289: ">"-token in bracketed URL !! wikitext [http://www.example.com/ stuff] !! html

<hello> stuff

!!end !! test T2289: literal ">"-token in bracketed URL !! wikitext [http://www.example.com/html stuff] !! html

html stuff

!!end !! test T2289: literal double quote at end of URL !! wikitext http://www.example.com/"hello" !! html

http://www.example.com/"hello"

!!end !! test T2289: literal double quote in bracketed URL !! wikitext [http://www.example.com/"hello" stuff] !! html

"hello" stuff

!!end !! test External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081) !! wikitext [http://www.example.com test] !! html

test

!! end !! test External links: link text with spaces !! wikitext [http://www.example.com a b c] [http://www.example.com ''a'' ''b''] !! html

a b c a b

!! 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/php

wikilink embedded in ext link

test wikilink embedded in ext link

!! html/parsoid

wikilink 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] !! html

http:/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/php

http://www.example.com/?title=AT%26T

!! html/parsoid

http://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/php

http://www.example.com/?title=100%25_Bran

!! html/parsoid

http://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/php

http://www.example.com/?title=Ben-Hur_%281959_film%29

!! html/parsoid

http://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

[1]

!! html/parsoid

!! end !! test T6781, T7267: %26 in autonumber URL !! wikitext [http://www.example.com/?title=100%25_Bran] !! html/php

[1]

!! html/parsoid

!! end !! test T6781, T7267: %28, %29 in autonumber URL !! wikitext [http://www.example.com/?title=Ben-Hur_%281959_film%29] !! html/php

[1]

!! html/parsoid

!! end !! test T6781: %26 in bracketed URL !! wikitext [http://www.example.com/?title=AT%26T link] !! html/php

link

!! html/parsoid

link

!! end !! test T6781, T7267: %25 in bracketed URL !! wikitext [http://www.example.com/?title=100%25_Bran link] !! html

link

!! end !! test T6781, T7267: %28, %29 in bracketed URL !! wikitext [http://www.example.com/?title=Ben-Hur_%281959_film%29 link] !! html/php

link

!! html/parsoid

link

!! end !! test External link containing a period in the anchor. (T65947) !! wikitext [//foo.org/bar#baz. bang] [//foo.org/bar. bang] !! html/php

bang

bang

!! html/parsoid

bang

bang

!! end !! test External link containing a single quote. (T65947) !! wikitext [//foo.org/bar'baz] [//foo.org/bar'baz bang] !! html/php

[1]

bang

!! html/parsoid

bang

!! end !! test External link containing double-single-quotes in text '' (T6598 check) !! wikitext Some [http://example.com/ pretty ''italics'' and stuff]! !! html

Some 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/php

Some pretty italics and stuff!

!! html/parsoid

Some 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/php

La muerte de Casagemas (1901) en el sitio de Museo Picasso.

!! html/parsoid

La 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

Google

!! html/parsoid

Google

!! end !! test External link to bare IPv4 address !! wikitext [http://192.168.0.1 Link] !! html/php

Link

!! html/parsoid

Link

!! end !! test URL-encoding in URL functions (single parameter) !! wikitext {{localurl:Some page|amp=&}} !! html

/index.php?title=Some_page&amp=&

!! end !! test URL-encoding in URL functions (multiple parameters) !! wikitext {{localurl:Some page|q=?&=&}} !! html

/index.php?title=Some_page&q=?&amp=&

!! end !! test Brackets in urls !! wikitext http://example.com/index.php?foozoid%5B%5D=bar http://example.com/index.php?foozoid[]=bar !! html/php

http://example.com/index.php?foozoid%5B%5D=bar

http://example.com/index.php?foozoid%5B%5D=bar

!! html/parsoid

http://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/php

http://[2404:130:0:1000::187:2]/index.php

Examples from RFC 2373, section 2.2:

Examples from RFC 2732, section 2:

!! html/parsoid

http://[2404:130:0:1000::187:2]/index.php

Examples from RFC 2373, section 2.2:

Examples from RFC 2732, section 2:

!! end # It might make sense to change this behavior; see # See https://phabricator.wikimedia.org/T238022#5665580 !! test Unicode text around autolinks !! wikitext größhttps://foo.org größ https://foo.org 아들 고건 사진https://foo.org 💩https://foo.org !! html/php

größhttps://foo.org

größ https://foo.org

아들 고건 사진https://foo.org

💩https://foo.org

!! html/parsoid

größhttps://foo.org

größ https://foo.org

아들 고건 사진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/php

test

Examples from RFC 2373, section 2.2:

Examples from RFC 2732, section 2:

!! html/parsoid

test

Examples 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

Search

!! html/parsoid

Search

!! end !! test Use url link syntax for links where the content is equal the link target !! wikitext http://example.com !! html/php

http://example.com

!! html/parsoid

http://example.com

!! 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)

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

foo

!! html/parsoid

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

foo

!! end !! test Parenthesis in external links, w/ transclusion or comment !! wikitext (http://example.com/{{1x|hi}}) (http://example.com) !! html/php

(http://example.com/hi)

(http://example.com)

!! html/parsoid

(http://example.com/hi)

(http://example.com)

!! 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

[1]

!! end !! test Parsoid extlink with _self target !! options externallinktarget=_self !! wikitext [https://www.example.com] !! html/parsoid

!! html/php

[1]

!! end