mirror of https://github.com/qt/qtbase.git
QUrl::resolved: keep treating file:name.txt as relative for now
8a33077
made QUrl::resolved() follow its documentation ("If relative is not a relative URL, this function will return relative directly.", where relative means scheme is empty). However there is much code out there (e.g. qtdeclarative) which relies on QUrl::fromLocalFile("fileName.txt") to be treated as relative, so for now, we still allow this (in Qt 5.6.x). For Qt 5.8, this commit will be reverted. [ChangeLog][QtCore][QUrl] [EDITORIAL: replaces8a33077
] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. For now it still treats "file:name.txt" as relative for compatibility, but be warned that in Qt 5.8 it will no longer consider those to be relative. Both isRelative() and RFC 3986 say that such URLs are not relative, so starting from Qt 5.8, resolved() will return them as is. Change-Id: Iff01e5b470319f6c46526086d765187e2259bdf5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
47511046a4
commit
91a2c8630b
|
@ -3167,7 +3167,8 @@ QUrl QUrl::resolved(const QUrl &relative) const
|
|||
if (!relative.d) return *this;
|
||||
|
||||
QUrl t;
|
||||
if (!relative.d->scheme.isEmpty()) {
|
||||
// Compatibility hack (mostly for qtdeclarative) : treat "file:relative.txt" as relative even though QUrl::isRelative() says false
|
||||
if (!relative.d->scheme.isEmpty() && (!relative.isLocalFile() || QDir::isAbsolutePath(relative.d->path))) {
|
||||
t = relative;
|
||||
t.detach();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue