aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2020-06-10 13:23:58 +0200
committerRoland Knall <rknall@gmail.com>2020-06-10 12:49:18 +0000
commit6f700a9da61c38b9b2b492a5ea6810f73e6c66b1 (patch)
tree958816277064f621566a922773c526863829022b /ui
parent0d10d8e6e88863db82f27b68dfb592cec7a600f2 (diff)
Qt: Fix zip import/export on Windows
On Windows, cleaning up the filename inside the zip failed due to the backslash not properly being recognized. This lead to profiles, which could not be imported on another machine, if the filename contained a path not existing there. Bug: 16608 Change-Id: Ib30b2370e30c30ac60f283edf6376c07258c25b6 Reviewed-on: https://code.wireshark.org/review/37437 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/utils/wireshark_zip_helper.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/ui/qt/utils/wireshark_zip_helper.cpp b/ui/qt/utils/wireshark_zip_helper.cpp
index 5d9ab500f6..627aa9d82d 100644
--- a/ui/qt/utils/wireshark_zip_helper.cpp
+++ b/ui/qt/utils/wireshark_zip_helper.cpp
@@ -65,12 +65,26 @@ bool WiresharkZipHelper::unzip(QString zipFile, QString directory, bool (*fileCh
QString fileInZip(filename_inzip);
int fileSize = static_cast<int>(file_info.uncompressed_size);
- /* Sanity check for the filen */
+ /* Sanity check for the file */
if (fileInZip.length() == 0 || (fileCheck && ! fileCheck(fileInZip, fileSize)) )
continue;
if (di.exists())
{
+#ifdef _WIN32
+ /* This is an additional fix for bug 16608, in which exports did contain the full path they
+ * where exported from, leading to imports not possible if the path does not exist on that
+ * machine */
+
+ if (fileInZip.contains(":/") || fileInZip.contains(":\\"))
+ {
+ QFileInfo fileName(fileInZip);
+ QFileInfo path(fileName.dir(), "");
+ QString newFile = path.baseName() + "/" + fileName.baseName();
+ fileInZip = newFile;
+ }
+#endif
+
QString fullPath = di.path() + "/" + fileInZip;
QFileInfo fi(fullPath);
QString dirPath = fi.absolutePath();
@@ -232,7 +246,8 @@ bool WiresharkZipHelper::zip(QString fileName, QStringList files, QString relati
{
QFileInfo sf(files.at(cnt));
QString fileInZip = sf.absoluteFilePath();
- fileInZip.replace(relativeTo, "");
+ QFileInfo relat(relativeTo);
+ fileInZip.replace(relat.absoluteFilePath(), "");
/* Windows cannot open zip files, if the filenames starts with a separator */
while (fileInZip.length() > 0 && fileInZip.startsWith("/"))
fileInZip = fileInZip.right(fileInZip.length() - 1);