diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-11-30 16:31:36 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-12-03 14:36:27 +0200 |
commit | 5f0df8562132dfc77dbdb352712e6d42efc35122 (patch) | |
tree | e6ef1369c7406933a5a71029a1a399020717eec7 /src/libs | |
parent | eca91dcdca76fbde8050629631f06518109f9d02 (diff) |
Libarchive: fix handling of glob pattern arguments when creating archive
Arguments with wildcards were not working if archivegen was called from
somewhere else than shell, like from within a Python script.
Task-number: QTIFW-2423
Change-Id: Icf6d6c3c45ad9050a03c1a3dd7c4d9f10d1f3be6
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/libarchivearchive.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libs/installer/libarchivearchive.cpp b/src/libs/installer/libarchivearchive.cpp index d3a79bd40..0e29be205 100644 --- a/src/libs/installer/libarchivearchive.cpp +++ b/src/libs/installer/libarchivearchive.cpp @@ -481,12 +481,32 @@ bool LibArchiveArchive::create(const QStringList &data) QScopedPointer<archive, ScopedPointerWriterDeleter> writer(archive_write_new()); configureWriter(writer.get()); + QStringList globbedData; + for (auto &dataEntry : data) { // Expand glob pattern entries with proper filenames + if (!dataEntry.contains(QLatin1Char('*'))) { + globbedData.append(dataEntry); + continue; + } + const QFileInfo entryInfo(dataEntry); + if (entryInfo.path().contains(QLatin1Char('*'))) { + setErrorString(QString::fromLatin1("Invalid argument \"%1\": glob patterns " + "are not supported between directory paths.").arg(dataEntry)); + return false; + } + const QDir parentDir = entryInfo.dir(); + const QList<QFileInfo> infoList = parentDir.entryInfoList(QStringList() + << entryInfo.fileName(), QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot); + + for (auto &info : infoList) + globbedData.append(info.absoluteFilePath()); + } + try { int status; if ((status = archive_write_open_filename(writer.get(), m_data->file.fileName().toLocal8Bit()))) throw Error(QLatin1String(archive_error_string(writer.get()))); - for (auto &dataEntry : data) { + for (auto &dataEntry : globbedData) { QScopedPointer<archive, ScopedPointerReaderDeleter> reader(archive_read_disk_new()); configureDiskReader(reader.get()); |