QMimeDatabase: fix mimeTypeForUrl for mailto URLs
The "path" of a mailto URL isn't a file, so we shouldn't try to do glob-based matching. I was getting application/x-ms-dos-executable for a .com domain and application/x-perl for a .pl domain... Change-Id: Ifc346c3bba83ba1a8476db3202492f4c2e4d52bb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d9c187b390
commit
16fa29352b
@ -515,7 +515,7 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const
|
||||
return mimeTypeForFile(url.toLocalFile());
|
||||
|
||||
const QString scheme = url.scheme();
|
||||
if (scheme.startsWith(QLatin1String("http")))
|
||||
if (scheme.startsWith(QLatin1String("http")) || scheme == QLatin1String("mailto"))
|
||||
return mimeTypeForName(d->defaultMimeType());
|
||||
|
||||
return mimeTypeForFile(url.path());
|
||||
|
@ -518,6 +518,8 @@ void tst_QMimeDatabase::mimeTypeForUrl()
|
||||
QVERIFY(db.mimeTypeForUrl(QUrl::fromEncoded("http://foo/bar.png")).isDefault()); // HTTP can't know before downloading
|
||||
QCOMPARE(db.mimeTypeForUrl(QUrl::fromEncoded("ftp://foo/bar.png")).name(), QString::fromLatin1("image/png"));
|
||||
QCOMPARE(db.mimeTypeForUrl(QUrl::fromEncoded("ftp://foo/bar")).name(), QString::fromLatin1("application/octet-stream")); // unknown extension
|
||||
QCOMPARE(db.mimeTypeForUrl(QUrl("mailto:something@example.com")).name(), QString::fromLatin1("application/octet-stream")); // unknown
|
||||
QCOMPARE(db.mimeTypeForUrl(QUrl("mailto:something@polish.pl")).name(), QString::fromLatin1("application/octet-stream")); // unknown, NOT perl ;)
|
||||
}
|
||||
|
||||
void tst_QMimeDatabase::mimeTypeForData_data()
|
||||
|
Loading…
Reference in New Issue
Block a user