Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Update
libqt5-qtbase
QMimeDatabase-follow-symlinks-when-checking-for...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File QMimeDatabase-follow-symlinks-when-checking-for-FIFO.patch of Package libqt5-qtbase
From 72b4f0d4743826ee14ec06bf0ada26418f4a69be Mon Sep 17 00:00:00 2001 From: David Faure <david.faure@kdab.com> Date: Mon, 30 Nov 2015 12:03:18 +0100 Subject: [PATCH 1/1] QMimeDatabase: follow symlinks when checking for FIFO etc. This was documented, but not what the code did. Task-number: QTBUG-48529 Change-Id: I4849778c61dcae13be27c62b24717693c0c07d78 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/mimetypes/qmimedatabase.cpp | 3 ++- .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 27 ++++++++++++++++++++++ .../mimetypes/qmimedatabase/tst_qmimedatabase.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index c1e17b9..fd11dbc 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -354,9 +354,10 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mo #ifdef Q_OS_UNIX // Cannot access statBuf.st_mode from the filesystem engine, so we have to stat again. + // In addition we want to follow symlinks. const QByteArray nativeFilePath = QFile::encodeName(file.fileName()); QT_STATBUF statBuffer; - if (QT_LSTAT(nativeFilePath.constData(), &statBuffer) == 0) { + if (QT_STAT(nativeFilePath.constData(), &statBuffer) == 0) { if (S_ISCHR(statBuffer.st_mode)) return d->mimeTypeForName(QLatin1String("inode/chardevice")); if (S_ISBLK(statBuffer.st_mode)) diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 0171c4a..1b4dc02 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -35,6 +35,11 @@ #include "qstandardpaths.h" +#ifdef Q_OS_UNIX +#include <sys/types.h> +#include <sys/stat.h> +#endif + #include <QtCore/QFile> #include <QtCore/QFileInfo> #include <QtCore/QStandardPaths> @@ -646,6 +651,28 @@ void tst_QMimeDatabase::knownSuffix() QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.tar.bz2")), QString::fromLatin1("tar.bz2")); } +void tst_QMimeDatabase::symlinkToFifo() // QTBUG-48529 +{ +#ifdef Q_OS_UNIX + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + const QString dir = tempDir.path(); + const QString fifo = dir + "/fifo"; + QCOMPARE(mkfifo(QFile::encodeName(fifo), 0006), 0); + + QMimeDatabase db; + QCOMPARE(db.mimeTypeForFile(fifo).name(), QString::fromLatin1("inode/fifo")); + + // Now make a symlink to the fifo + const QString link = dir + "/link"; + QVERIFY(QFile::link(fifo, link)); + QCOMPARE(db.mimeTypeForFile(link).name(), QString::fromLatin1("inode/fifo")); + +#else + QSKIP("This test requires pipes and symlinks"); +#endif +} + void tst_QMimeDatabase::findByFileName_data() { QTest::addColumn<QString>("filePath"); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h index 2827bd2..4b703f1 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h @@ -70,6 +70,7 @@ private slots: void suffixes_data(); void suffixes(); void knownSuffix(); + void symlinkToFifo(); void fromThreads(); // shared-mime-info test suite -- 2.6.2.2.g1b5ffa3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor