Prevent URL-encoding of characters in link in Medi

2019-04-16 19:55发布

问题:

I.e.: How to suppress substitution/replacement of characters with its html entities in a MediaWiki link?

I need to insert a link looking like this, pipes (|) included, into a MediaWiki article:

http://www.somesite.asdf/#|param1|param2|param3

The target site does not accept %7C or | as pipe-substitutes in its URL. Ergo, the following URLs are invalid:

http://www.somesite.asdf/#%7Cparam1%7Cparam2%7Cparam3
http://www.somesite.asdf/#|param1|param2|param3

When I type the link into the MediaWiki-article like:

http://www.somesite.asdf/#|param1|param2|param3

... it results in a link pointing to:

http://www.somesite.asdf/#%7Cparam1%7Cparam2%7Cparam3

, which is not valid.

Any suggestions?

回答1:

That is not a valid URI; per RFC 3986, an URI consists of the characters ALPHA / DIGIT / "-" / "." / "_" / "~" / ":" / "/" / "?" / "#" / "[" / "]" / "@" / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="; everything else must be percent-encoded. MediaWiki automatically corrects invalid URLs (as would any other CMS, probably), so if this wiki is owned by someone else, you are out of luck. If it is yours, you can use some method to avoid the built-in HTML processing (e. g. enable the <html> tag); make sure you know what you are doing, this usually has security consequences.