When one creates/edits an external link that contains an '_' in its link URL the URL gets split at the '_' and the part after the first '_' becomes part of the link text.
This is due to the fact that in tinymce/plugins/mw_wikicode/plugin.js
the insertLink function replaces every '_' in the URL with a space (' ') even for external links. And that's a bug as this should only be done for internal links (if at all).
My solution for this are these changes to that file:
--- a/tinymce/plugins/mw_wikicode/plugin.js +++ b/tinymce/plugins/mw_wikicode/plugin.js @@ -2894,11 +2894,12 @@ var MwWikiCode = function() { //This is necessary to avoid the bswikicode parser from breaking the markup var href = data.href.replace(/(^.*?\[|\].*?$|\r\n|\r|\n)/gm, ''); //first layer of '[...]' //external-, file- and mailto- links'' href = href.replace(/(^.*?\[|\].*?$|\r\n|\r|\n)/gm, ''); //potential second layer of '[[...]]' //internal and interwiki links'' - var aLink = decodeURIComponent(href).replace("_"," "); + var aLink = decodeURIComponent(href); var aLabel = decodeURI(data.text).replace("_"," "); var wikitext = ""; if (data["class"] == "link internal mw-internal-link mceNonEditable") { + aLink = aLink.replace("_"," "); if (aLabel) { wikitext = "[[" + aLink + "|" + aLabel + "]]"; } else {
Is this a valid solution or am I missing something?