#69505Rte modify Iframe / script protocol-relative url with firefox
Description
With firefox 40.0.3, when I add iframe or script with protocol-relative url (// instead of http:// or https://), after second save or editing code the url, the url //test.com is transformed into http://urlOfWebSite/typo3///test.com …
In htmlarea.js, a firefox bug require a special treatment for urls. This treatement prefixe urls without protocol (function addBaseUrl).
} else if (Ext.isGecko) {
// Ignore special values reported by Mozilla
if (/(_moz|^$)/.test(attributeValue)) {
continue;
// Pasted internal url's are made relative by Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=613517
} else if (attributeName === 'href' || attributeName === 'src') {
attributeValue = HTMLArea.DOM.addBaseUrl(attributeValue, this.baseUrl);
}
}
But this addBaseUrl omit protocol-relative url case.
The regex is : ^[a-z0-9_]{2,}\:
addBaseUrl: function (url, baseUrl) {
var absoluteUrl = url;
// If the url has no scheme...
if (!/^[a-z0-9_]{2,}\:/i.test(absoluteUrl)) {
var base = baseUrl;
while (absoluteUrl.match(/^\.\.\/(.*)/)) {
// Remove leading ../ from url
absoluteUrl = RegExp.$1;
base.match(/(.*\:\/\/.*\/)[^\/]+\/$/);
// Remove lowest directory level from base
base = RegExp.$1;
absoluteUrl = base + absoluteUrl;
}
// If the url is still not absolute...
if (!/^.*\:\/\//.test(absoluteUrl)) {
absoluteUrl = baseUrl + absoluteUrl;
}
}
return absoluteUrl;
}
The good regex shoud be : ^([a-z0-9_]{2,}\:|[\/\/])
PS: I lost all my hair to find this bug