Project

General

Profile

Actions

Bug #69505

closed

Rte modify Iframe / script protocol-relative url with firefox

Added by Nicolas Forgeot almost 9 years ago. Updated about 7 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
-
Start date:
2015-09-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

https://git.typo3.org/Packages/TYPO3.CMS.git/blob/2e7ea604c4ee75bb50d7df9b63d6d1add8b2e1a6:/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js#l3516

} 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,}\:

https://git.typo3.org/Packages/TYPO3.CMS.git/blob/2e7ea604c4ee75bb50d7df9b63d6d1add8b2e1a6:/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js#l3350

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

Actions

Also available in: Atom PDF