ubc / wiki-embed

WordPress plugin that lets you embed mediawiki pages into your site, sites like Wikipedia
19 stars 10 forks source link

wiki-embed breaks protocol-relative links #10

Open nemobis opened 8 years ago

nemobis commented 8 years ago

With wiki-embed 1.4.6, an URL which action=render outputs as

<a class="external text" href="//commons.wikimedia.org/w/index.php?title=Page">Page</a>

is stripped down to

 <a class="external text" href="Page">Page</a>

which of course doesn't exist locally and hence produces a 404 error.

I've looked into Wiki_Embed::render() and the DOMCSS rules but I couldn't find what is at fault. Am I looking in the wrong place?

Someone at some point claimed this (or similar) was a bug in PHP but then self-closed the bug: https://bugs.php.net/bug.php?id=64946

nemobis commented 6 years ago

This was also true for internal links.

On a wiki with $wgServer set to a protocol-relative URL, [[:File:Example.png]] becomes something like <a href="/wiki/File:Example.png" title="/wiki/File:Example.png"> and is kept as such on Wordpress, although www.example.org/wiki/File:Example.png doesn't exist.

After I set wgServer to be a HTTPS URL, the HTML is transformed and the link is preserved as https://wiki.example.org/wiki/File:Example.png.