Hello community, here is the log from the commit of package quazip for openSUSE:Factory checked in at 2019-06-03 18:57:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/quazip (Old) and /work/SRC/openSUSE:Factory/.quazip.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "quazip" Mon Jun 3 18:57:28 2019 rev:19 rq:707103 version:0.8.1 Changes: -------- --- /work/SRC/openSUSE:Factory/quazip/quazip.changes 2019-04-08 10:36:20.315220003 +0200 +++ /work/SRC/openSUSE:Factory/.quazip.new.5148/quazip.changes 2019-06-03 18:57:29.628381597 +0200 @@ -1,0 +2,11 @@ +Sun Jun 2 20:06:35 UTC 2019 - Luigi Baldoni <[email protected]> + +- Update to version 0.8.1 + * A bugfix release. Fixes a regression in CMake. + version 0.8 + * Support for UTF-8 in file names and comments + (Denis Zavorotnyy) + * get/setOsCode(), get/setDefaultOsCode() + * Fixed Z_STREAM_END handling in QuaZioDevice + +------------------------------------------------------------------- Old: ---- quazip-0.7.6.tar.gz New: ---- quazip-0.8.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ quazip.spec ++++++ --- /var/tmp/diff_new_pack.zA4qvB/_old 2019-06-03 18:57:30.472381285 +0200 +++ /var/tmp/diff_new_pack.zA4qvB/_new 2019-06-03 18:57:30.476381283 +0200 @@ -18,21 +18,21 @@ %define so_ver 1 Name: quazip -Version: 0.7.6 +Version: 0.8.1 Release: 0 Summary: C++ wrapper for ZIP/UNZIP License: GPL-2.0-or-later OR LGPL-2.1-or-later Group: Development/Libraries/C and C++ URL: https://github.com/stachenov/quazip -Source: https://github.com/stachenov/quazip/archive/%{version}.tar.gz#/quazip-%{version}.tar.gz +Source: https://github.com/stachenov/quazip/archive/v%{version}.tar.gz#/quazip-%{version}.tar.gz BuildRequires: cmake BuildRequires: doxygen BuildRequires: fdupes BuildRequires: graphviz BuildRequires: graphviz-gnome BuildRequires: pkgconfig -BuildRequires: zlib-devel BuildRequires: pkgconfig(Qt5Core) +BuildRequires: pkgconfig(zlib) %description A C++ wrapper for the Gilles Vollant's ZIP/UNZIP C package, using Qt5 toolkit. @@ -78,7 +78,7 @@ %setup -q -n quazip-%{version} %build -%cmake -DCMAKE_CXX_FLAGS="-fPIC" +%cmake %make_jobs cd .. @@ -89,6 +89,10 @@ %install %cmake_install rm %{buildroot}/%{_libdir}/libquazip5.a +# install docs +mkdir -pv %{buildroot}%{_defaultdocdir}/quazip-doc +cp -r doc/html %{buildroot}%{_defaultdocdir}/quazip-doc/ +%fdupes -s %{buildroot}%{_defaultdocdir}/quazip-doc %post -n libquazip5-%{so_ver} -p /sbin/ldconfig %postun -n libquazip5-%{so_ver} -p /sbin/ldconfig @@ -100,11 +104,11 @@ %files devel %license COPYING* +%{_datadir}/cmake/Modules/FindQuaZip5.cmake %{_includedir}/quazip5/ %{_libdir}/libquazip5.so -%{_datadir}/cmake/Modules/FindQuaZip5.cmake %files doc -%doc doc/html +%doc %{_defaultdocdir}/quazip-doc %changelog ++++++ quazip-0.7.6.tar.gz -> quazip-0.8.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/CMakeLists.txt new/quazip-0.8.1/CMakeLists.txt --- old/quazip-0.7.6/CMakeLists.txt 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/CMakeLists.txt 2019-05-27 06:27:44.000000000 +0200 @@ -1,5 +1,5 @@ -project(QuaZip) cmake_minimum_required(VERSION 2.6) +project(QuaZip) # CMP0042: Explicitly acknowledge MACOSX_RPATH # (introduced in CMake 2.8.12, enabled by default in CMake 3.0, @@ -60,4 +60,4 @@ add_subdirectory(quazip) -install(FILES FindQuaZip.cmake RENAME FindQuaZip${QUAZIP_LIB_VERSION_SUFFIX}.cmake DESTINATION ${CMAKE_ROOT}/Modules) +install(FILES FindQuaZip.cmake RENAME FindQuaZip${QUAZIP_LIB_VERSION_SUFFIX}.cmake DESTINATION share/cmake/Modules) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/NEWS.txt new/quazip-0.8.1/NEWS.txt --- old/quazip-0.7.6/NEWS.txt 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/NEWS.txt 2019-05-27 06:27:44.000000000 +0200 @@ -1,5 +1,10 @@ QuaZIP changes +* 2019-05-23 0.8 + * Support for UTF-8 in file names and comments (Denis Zavorotnyy) + * get/setOsCode(), get/setDefaultOsCode() + * Fixed Z_STREAM_END handling in QuaZioDevice + * 2018-06-13 0.7.6 * Fixed the Zip Slip vulnerability in JlCompress * Renamed crypt.h to minizip_crypt.h to avoid conflicts diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/JlCompress.cpp new/quazip-0.8.1/quazip/JlCompress.cpp --- old/quazip-0.7.6/quazip/JlCompress.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/JlCompress.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -92,7 +92,7 @@ if (dir != origDir) { QuaZipFile dirZipFile(zip); if (!dirZipFile.open(QIODevice::WriteOnly, - QuaZipNewInfo(origDirectory.relativeFilePath(dir) + "/", dir), 0, 0, 0)) { + QuaZipNewInfo(origDirectory.relativeFilePath(dir) + QLatin1String("/"), dir), 0, 0, 0)) { return false; } dirZipFile.close(); @@ -148,7 +148,7 @@ // Controllo esistenza cartella file risultato QDir curDir; - if (fileDest.endsWith('/')) { + if (fileDest.endsWith(QLatin1String("/"))) { if (!curDir.mkpath(fileDest)) { return false; } @@ -163,7 +163,7 @@ return false; QFile::Permissions srcPerm = info.getPermissions(); - if (fileDest.endsWith('/') && QFileInfo(fileDest).isDir()) { + if (fileDest.endsWith(QLatin1String("/")) && QFileInfo(fileDest).isDir()) { if (srcPerm != 0) { QFile(fileDest).setPermissions(srcPerm); } @@ -375,9 +375,9 @@ QString name = zip.getCurrentFileName(); QString absFilePath = directory.absoluteFilePath(name); QString absCleanPath = QDir::cleanPath(absFilePath); - if (!absCleanPath.startsWith(absCleanDir + "/")) + if (!absCleanPath.startsWith(absCleanDir + QLatin1String("/"))) continue; - if (!extractFile(&zip, "", absFilePath)) { + if (!extractFile(&zip, QLatin1String(""), absFilePath)) { removeFile(extracted); return QStringList(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/ioapi.h new/quazip-0.8.1/quazip/ioapi.h --- old/quazip-0.7.6/quazip/ioapi.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/ioapi.h 2019-05-27 06:27:44.000000000 +0200 @@ -44,7 +44,7 @@ #include <stdio.h> #include <stdlib.h> -#include "zlib.h" +#include <zlib.h> #if defined(USE_FILE32API) #define fopen64 fopen diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/qioapi.cpp new/quazip-0.8.1/quazip/qioapi.cpp --- old/quazip-0.7.6/quazip/qioapi.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/qioapi.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -11,8 +11,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <zlib.h> -#include "zlib.h" #include "ioapi.h" #include "quazip_global.h" #include <QIODevice> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quaadler32.cpp new/quazip-0.8.1/quazip/quaadler32.cpp --- old/quazip-0.7.6/quazip/quaadler32.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quaadler32.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -25,7 +25,7 @@ #include "quaadler32.h" -#include "zlib.h" +#include <zlib.h> QuaAdler32::QuaAdler32() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quacrc32.cpp new/quazip-0.8.1/quazip/quacrc32.cpp --- old/quazip-0.7.6/quazip/quacrc32.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quacrc32.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -24,7 +24,7 @@ #include "quacrc32.h" -#include "zlib.h" +#include <zlib.h> QuaCrc32::QuaCrc32() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quaziodevice.cpp new/quazip-0.8.1/quazip/quaziodevice.cpp --- old/quazip-0.7.6/quazip/quaziodevice.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quaziodevice.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -30,9 +30,10 @@ /// \cond internal class QuaZIODevicePrivate { friend class QuaZIODevice; - QuaZIODevicePrivate(QIODevice *io); + QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q); ~QuaZIODevicePrivate(); QIODevice *io; + QuaZIODevice *q; z_stream zins; z_stream zouts; char *inBuf; @@ -43,11 +44,13 @@ int outBufSize; bool zBufError; bool atEnd; + bool flush(int sync); int doFlush(QString &error); }; -QuaZIODevicePrivate::QuaZIODevicePrivate(QIODevice *io): +QuaZIODevicePrivate::QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q): io(io), + q(q), inBuf(NULL), inBufPos(0), inBufSize(0), @@ -86,7 +89,45 @@ if (inBuf != NULL) delete[] inBuf; if (outBuf != NULL) - delete[] outBuf; + delete[] outBuf; +} + +bool QuaZIODevicePrivate::flush(int sync) +{ + QString error; + if (doFlush(error) < 0) { + q->setErrorString(error); + return false; + } + // can't flush buffer, some data is still waiting + if (outBufPos < outBufSize) + return true; + Bytef c = 0; + zouts.next_in = &c; // fake input buffer + zouts.avail_in = 0; // of zero size + do { + zouts.next_out = (Bytef *) outBuf; + zouts.avail_out = QUAZIO_OUTBUFSIZE; + int result = deflate(&zouts, sync); + switch (result) { + case Z_OK: + case Z_STREAM_END: + outBufSize = (char *) zouts.next_out - outBuf; + if (doFlush(error) < 0) { + q->setErrorString(error); + return false; + } + if (outBufPos < outBufSize) + return true; + break; + case Z_BUF_ERROR: // nothing to write? + return true; + default: + q->setErrorString(QString::fromLocal8Bit(zouts.msg)); + return false; + } + } while (zouts.avail_out == 0); + return true; } int QuaZIODevicePrivate::doFlush(QString &error) @@ -124,7 +165,7 @@ QuaZIODevice::QuaZIODevice(QIODevice *io, QObject *parent): QIODevice(parent), - d(new QuaZIODevicePrivate(io)) + d(new QuaZIODevicePrivate(io, this)) { connect(io, SIGNAL(readyRead()), SIGNAL(readyRead())); } @@ -155,13 +196,13 @@ } if ((mode & QIODevice::ReadOnly) != 0) { if (inflateInit(&d->zins) != Z_OK) { - setErrorString(d->zins.msg); + setErrorString(QString::fromLocal8Bit(d->zins.msg)); return false; } } if ((mode & QIODevice::WriteOnly) != 0) { if (deflateInit(&d->zouts, Z_DEFAULT_COMPRESSION) != Z_OK) { - setErrorString(d->zouts.msg); + setErrorString(QString::fromLocal8Bit(d->zouts.msg)); return false; } } @@ -172,13 +213,13 @@ { if ((openMode() & QIODevice::ReadOnly) != 0) { if (inflateEnd(&d->zins) != Z_OK) { - setErrorString(d->zins.msg); + setErrorString(QString::fromLocal8Bit(d->zins.msg)); } } if ((openMode() & QIODevice::WriteOnly) != 0) { - flush(); + d->flush(Z_FINISH); if (deflateEnd(&d->zouts) != Z_OK) { - setErrorString(d->zouts.msg); + setErrorString(QString::fromLocal8Bit(d->zouts.msg)); } } QIODevice::close(); @@ -283,38 +324,7 @@ bool QuaZIODevice::flush() { - QString error; - if (d->doFlush(error) < 0) { - setErrorString(error); - return false; - } - // can't flush buffer, some data is still waiting - if (d->outBufPos < d->outBufSize) - return true; - Bytef c = 0; - d->zouts.next_in = &c; // fake input buffer - d->zouts.avail_in = 0; // of zero size - do { - d->zouts.next_out = (Bytef *) d->outBuf; - d->zouts.avail_out = QUAZIO_OUTBUFSIZE; - switch (deflate(&d->zouts, Z_SYNC_FLUSH)) { - case Z_OK: - d->outBufSize = (char *) d->zouts.next_out - d->outBuf; - if (d->doFlush(error) < 0) { - setErrorString(error); - return false; - } - if (d->outBufPos < d->outBufSize) - return true; - break; - case Z_BUF_ERROR: // nothing to write? - return true; - default: - setErrorString(QString::fromLocal8Bit(d->zouts.msg)); - return false; - } - } while (d->zouts.avail_out == 0); - return true; + return d->flush(Z_SYNC_FLUSH); } bool QuaZIODevice::isSequential() const diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quaziodevice.h new/quazip-0.8.1/quazip/quaziodevice.h --- old/quazip-0.7.6/quazip/quaziodevice.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quaziodevice.h 2019-05-27 06:27:44.000000000 +0200 @@ -39,6 +39,7 @@ example. */ class QUAZIP_EXPORT QuaZIODevice: public QIODevice { + friend class QuaZIODevicePrivate; Q_OBJECT public: /// Constructor. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazip.cpp new/quazip-0.8.1/quazip/quazip.cpp --- old/quazip-0.7.6/quazip/quazip.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazip.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -28,6 +28,8 @@ #include "quazip.h" +#define QUAZIP_OS_UNIX 3u + /// All the internal stuff for the QuaZip class. /** \internal @@ -42,9 +44,9 @@ Q_DISABLE_COPY(QuaZipPrivate) /// The pointer to the corresponding QuaZip instance. QuaZip *q; - /// The codec for file names. + /// The codec for file names (used when UTF-8 is not enabled). QTextCodec *fileNameCodec; - /// The codec for comments. + /// The codec for comments (used when UTF-8 is not enabled). QTextCodec *commentCodec; /// The archive file name. QString zipName; @@ -70,6 +72,10 @@ bool zip64; /// The auto-close flag. bool autoClose; + /// The UTF-8 flag. + bool utf8; + /// The OS code. + uint osCode; inline QTextCodec *getDefaultFileNameCodec() { if (defaultFileNameCodec == NULL) { @@ -89,7 +95,9 @@ zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), - autoClose(true) + autoClose(true), + utf8(false), + osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; @@ -108,7 +116,9 @@ zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), - autoClose(true) + autoClose(true), + utf8(false), + osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; @@ -117,7 +127,7 @@ } /// The constructor for the corresponding QuaZip constructor. inline QuaZipPrivate(QuaZip *q, QIODevice *ioDevice): - q(q), + q(q), fileNameCodec(getDefaultFileNameCodec()), commentCodec(QTextCodec::codecForLocale()), ioDevice(ioDevice), @@ -126,7 +136,9 @@ zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), - autoClose(true) + autoClose(true), + utf8(false), + osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; @@ -145,9 +157,11 @@ QHash<QString, unz64_file_pos> directoryCaseInsensitive; unz64_file_pos lastMappedDirectoryEntry; static QTextCodec *defaultFileNameCodec; + static uint defaultOsCode; }; QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL; +uint QuaZipPrivate::defaultOsCode = QUAZIP_OS_UNIX; void QuaZipPrivate::clearDirectoryMap() { @@ -280,6 +294,8 @@ flags |= ZIP_AUTO_CLOSE; if (p->dataDescriptorWritingEnabled) flags |= ZIP_WRITE_DATA_DESCRIPTOR; + if (p->utf8) + flags |= ZIP_ENCODING_UTF8; p->zipFile_f=zipOpen3(ioDevice, mode==mdCreate?APPEND_STATUS_CREATE: mode==mdAppend?APPEND_STATUS_CREATEAFTER: @@ -341,9 +357,9 @@ case mdCreate: case mdAppend: case mdAdd: - p->zipError=zipClose(p->zipFile_f, - p->comment.isNull() ? NULL - : p->commentCodec->fromUnicode(p->comment).constData()); + p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? NULL : isUtf8Enabled() + ? p->comment.toUtf8().constData() + : p->commentCodec->fromUnicode(p->comment).constData()); break; default: qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode); @@ -409,7 +425,9 @@ if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0) return QString(); fakeThis->p->zipError = UNZ_OK; - return p->commentCodec->toUnicode(comment); + unsigned flags = 0; + return (unzGetFileFlags(p->unzFile_f, &flags) == UNZ_OK) && (flags & UNZ_ENCODING_UTF8) + ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); } bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs) @@ -544,8 +562,8 @@ info->diskNumberStart=info_z.disk_num_start; info->internalAttr=info_z.internal_fa; info->externalAttr=info_z.external_fa; - info->name=p->fileNameCodec->toUnicode(fileName); - info->comment=p->commentCodec->toUnicode(comment); + info->name=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); + info->comment=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); info->extra=extra; info->dateTime=QDateTime( QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday), @@ -565,10 +583,13 @@ } if(!isOpen()||!hasCurrentFile()) return QString(); QByteArray fileName(MAX_FILE_NAME_LENGTH, 0); - if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, NULL, fileName.data(), fileName.size(), + unz_file_info64 file_info; + if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &file_info, fileName.data(), fileName.size(), NULL, 0, NULL, 0))!=UNZ_OK) return QString(); - QString result = p->fileNameCodec->toUnicode(fileName.constData()); + fileName.resize(file_info.size_filename); + QString result = (file_info.flag & UNZ_ENCODING_UTF8) + ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); if (result.isEmpty()) return result; // Add to directory map @@ -583,7 +604,17 @@ void QuaZip::setFileNameCodec(const char *fileNameCodecName) { - p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName); + p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName); +} + +void QuaZip::setOsCode(uint osCode) +{ + p->osCode = osCode; +} + +uint QuaZip::getOsCode() const +{ + return p->osCode; } QTextCodec *QuaZip::getFileNameCodec()const @@ -774,6 +805,16 @@ setDefaultFileNameCodec(QTextCodec::codecForName(codecName)); } +void QuaZip::setDefaultOsCode(uint osCode) +{ + QuaZipPrivate::defaultOsCode = osCode; +} + +uint QuaZip::getDefaultOsCode() +{ + return QuaZipPrivate::defaultOsCode; +} + void QuaZip::setZip64Enabled(bool zip64) { p->zip64 = zip64; @@ -784,6 +825,16 @@ return p->zip64; } +void QuaZip::setUtf8Enabled(bool utf8) +{ + p->utf8 = utf8; +} + +bool QuaZip::isUtf8Enabled() const +{ + return p->utf8; +} + bool QuaZip::isAutoClose() const { return p->autoClose; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazip.h new/quazip-0.8.1/quazip/quazip.h --- old/quazip-0.7.6/quazip/quazip.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazip.h 2019-05-27 06:27:44.000000000 +0200 @@ -227,6 +227,14 @@ * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); **/ void setFileNameCodec(const char *fileNameCodecName); + /// Sets the OS code (highest 8 bits of the “version made by” field) for new files. + /** There is currently no way to specify this for each file individually, + except by calling this function before opening each file. If this function is not called, + then the default OS code will be used. The default code is set by calling + setDefaultOsCode(). The default value at the moment of QuaZip creation will be used. */ + void setOsCode(uint osCode); + /// Returns the OS code for new files. + uint getOsCode() const; /// Returns the codec used to encode/decode comments inside archive. QTextCodec* getFileNameCodec() const; /// Sets the codec used to encode/decode comments inside archive. @@ -502,6 +510,28 @@ * \sa setZip64Enabled() */ bool isZip64Enabled() const; + /// Enables the use of UTF-8 encoding for file names and comments text. + /** + * @param utf8 If \c true, the UTF-8 mode is enabled, disabled otherwise. + * + * Once this is enabled, the names of all new files and comments text (until + * the mode is disabled again) will be encoded in UTF-8 encoding, and the + * version to extract will be set to 6.3 (63) in ZIP header. By default, + * the UTF-8 mode is off due to compatibility reasons. + * + * Note that when extracting ZIP archives, the UTF-8 mode is determined from + * ZIP file header, not from this flag. + * + * \sa isUtf8Enabled() + */ + void setUtf8Enabled(bool utf8); + /// Returns whether the UTF-8 encoding mode is enabled. + /** + * @return \c true if and only if the UTF-8 mode is enabled. + * + * \sa setUtf8Enabled() + */ + bool isUtf8Enabled() const; /// Returns the auto-close flag. /** @sa setAutoClose() @@ -563,9 +593,19 @@ /** * @overload * Equivalent to calling - * setDefltFileNameCodec(QTextCodec::codecForName(codecName)). + * setDefaultFileNameCodec(QTextCodec::codecForName(codecName)). */ static void setDefaultFileNameCodec(const char *codecName); + /// Sets default OS code. + /** + * @sa setOsCode() + */ + static void setDefaultOsCode(uint osCode); + /// Returns default OS code. + /** + * @sa getOsCode() + */ + static uint getDefaultOsCode(); }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazip.pro new/quazip-0.8.1/quazip/quazip.pro --- old/quazip-0.7.6/quazip/quazip.pro 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazip.pro 2019-05-27 06:27:44.000000000 +0200 @@ -32,7 +32,8 @@ # This one handles dllimport/dllexport directives. DEFINES += QUAZIP_BUILD - +DEFINES+=QT_NO_CAST_FROM_ASCII +DEFINES+=QT_NO_CAST_TO_ASCII # You'll need to define this one manually if using a build system other # than qmake or using QuaZIP sources directly in your project. CONFIG(staticlib): DEFINES += QUAZIP_STATIC diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazipdir.cpp new/quazip-0.8.1/quazip/quazipdir.cpp --- old/quazip-0.7.6/quazip/quazipdir.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazipdir.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -55,7 +55,7 @@ QuaZipDir::QuaZipDir(QuaZip *zip, const QString &dir): d(new QuaZipDirPrivate(zip, dir)) { - if (d->dir.startsWith('/')) + if (d->dir.startsWith(QLatin1String("/"))) d->dir = d->dir.mid(1); } @@ -86,24 +86,24 @@ bool QuaZipDir::cd(const QString &directoryName) { - if (directoryName == "/") { - d->dir = ""; + if (directoryName == QLatin1String("/")) { + d->dir = QLatin1String(""); return true; } QString dirName = directoryName; - if (dirName.endsWith('/')) + if (dirName.endsWith(QLatin1String("/"))) dirName.chop(1); - if (dirName.contains('/')) { + if (dirName.contains(QLatin1String("/"))) { QuaZipDir dir(*this); - if (dirName.startsWith('/')) { + if (dirName.startsWith(QLatin1String("/"))) { #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::cd(%s): going to /", dirName.toUtf8().constData()); #endif - if (!dir.cd("/")) + if (!dir.cd(QLatin1String("/"))) return false; } - QStringList path = dirName.split('/', QString::SkipEmptyParts); + QStringList path = dirName.split(QLatin1String("/"), QString::SkipEmptyParts); for (QStringList::const_iterator i = path.constBegin(); i != path.end(); ++i) { @@ -119,15 +119,15 @@ d->dir = dir.path(); return true; } else { // no '/' - if (dirName == ".") { + if (dirName == QLatin1String(".")) { return true; - } else if (dirName == "..") { + } else if (dirName == QLatin1String("..")) { if (isRoot()) { return false; } else { - int slashPos = d->dir.lastIndexOf('/'); + int slashPos = d->dir.lastIndexOf(QLatin1String("/")); if (slashPos == -1) { - d->dir = ""; + d->dir = QLatin1String(""); } else { d->dir = d->dir.left(slashPos); } @@ -138,7 +138,7 @@ if (isRoot()) d->dir = dirName; else - d->dir += "/" + dirName; + d->dir += QLatin1String("/") + dirName; return true; } else { return false; @@ -149,7 +149,7 @@ bool QuaZipDir::cdUp() { - return cd(".."); + return cd(QLatin1String("..")); } uint QuaZipDir::count() const @@ -247,10 +247,10 @@ QString QuaZipDirComparator::getExtension(const QString &name) { - if (name.endsWith('.') || name.indexOf('.', 1) == -1) { - return ""; + if (name.endsWith(QLatin1String(".")) || name.indexOf(QLatin1String("."), 1) == -1) { + return QLatin1String(""); } else { - return name.mid(name.lastIndexOf('.') + 1); + return name.mid(name.lastIndexOf(QLatin1String(".")) + 1); } } @@ -277,9 +277,9 @@ & (QDir::Name | QDir::Time | QDir::Size | QDir::Type); if ((sort & QDir::DirsFirst) == QDir::DirsFirst || (sort & QDir::DirsLast) == QDir::DirsLast) { - if (info1.name.endsWith('/') && !info2.name.endsWith('/')) + if (info1.name.endsWith(QLatin1String("/")) && !info2.name.endsWith(QLatin1String("/"))) return (sort & QDir::DirsFirst) == QDir::DirsFirst; - else if (!info1.name.endsWith('/') && info2.name.endsWith('/')) + else if (!info1.name.endsWith(QLatin1String("/")) && info2.name.endsWith(QLatin1String("/"))) return (sort & QDir::DirsLast) == QDir::DirsLast; } bool result; @@ -325,7 +325,7 @@ { QString basePath = simplePath(); if (!basePath.isEmpty()) - basePath += "/"; + basePath += QLatin1String("/"); int baseLength = basePath.length(); result.clear(); QuaZipDirRestoreCurrent saveCurrent(zip); @@ -351,8 +351,8 @@ continue; bool isDir = false; bool isReal = true; - if (relativeName.contains('/')) { - int indexOfSlash = relativeName.indexOf('/'); + if (relativeName.contains(QLatin1String("/"))) { + int indexOfSlash = relativeName.indexOf(QLatin1String("/")); // something like "subdir/" isReal = indexOfSlash == relativeName.length() - 1; relativeName = relativeName.left(indexOfSlash + 1); @@ -448,12 +448,12 @@ bool QuaZipDir::exists(const QString &filePath) const { - if (filePath == "/" || filePath.isEmpty()) + if (filePath == QLatin1String("/") || filePath.isEmpty()) return true; QString fileName = filePath; - if (fileName.endsWith('/')) + if (fileName.endsWith(QLatin1String("/"))) fileName.chop(1); - if (fileName.contains('/')) { + if (fileName.contains(QLatin1String("/"))) { QFileInfo fileInfo(fileName); #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::exists(): fileName=%s, fileInfo.fileName()=%s, " @@ -464,9 +464,9 @@ QuaZipDir dir(*this); return dir.cd(fileInfo.path()) && dir.exists(fileInfo.fileName()); } else { - if (fileName == "..") { + if (fileName == QLatin1String("..")) { return !isRoot(); - } else if (fileName == ".") { + } else if (fileName == QLatin1String(".")) { return true; } else { QStringList entries = entryList(QDir::AllEntries, QDir::NoSort); @@ -482,11 +482,11 @@ #endif Qt::CaseSensitivity cs = QuaZip::convertCaseSensitivity( d->caseSensitivity); - if (filePath.endsWith('/')) { + if (filePath.endsWith(QLatin1String("/"))) { return entries.contains(filePath, cs); } else { return entries.contains(fileName, cs) - || entries.contains(fileName + "/", cs); + || entries.contains(fileName + QLatin1String("/"), cs); } } } @@ -524,7 +524,7 @@ QString QuaZipDir::relativeFilePath(const QString &fileName) const { - return QDir("/" + d->dir).relativeFilePath(fileName); + return QDir(QLatin1String("/") + d->dir).relativeFilePath(fileName); } void QuaZipDir::setCaseSensitivity(QuaZip::CaseSensitivity caseSensitivity) @@ -545,12 +545,12 @@ void QuaZipDir::setPath(const QString &path) { QString newDir = path; - if (newDir == "/") { - d->dir = ""; + if (newDir == QLatin1String("/")) { + d->dir = QLatin1String(""); } else { - if (newDir.endsWith('/')) + if (newDir.endsWith(QLatin1String("/"))) newDir.chop(1); - if (newDir.startsWith('/')) + if (newDir.startsWith(QLatin1String("/"))) newDir = newDir.mid(1); d->dir = newDir; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazipfile.cpp new/quazip-0.8.1/quazip/quazipfile.cpp --- old/quazip-0.7.6/quazip/quazipfile.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazipfile.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -26,6 +26,8 @@ using namespace std; +#define QUAZIP_VERSION_MADE_BY 0x1Eu + /// The implementation class for QuaZip. /** \internal @@ -112,7 +114,7 @@ { zip=new QuaZip(zipName); this->fileName=fileName; - if (this->fileName.startsWith('/')) + if (this->fileName.startsWith(QLatin1String("/"))) this->fileName = this->fileName.mid(1); this->caseSensitivity=cs; } @@ -232,7 +234,7 @@ return; } p->fileName=fileName; - if (p->fileName.startsWith('/')) + if (p->fileName.startsWith(QLatin1String("/"))) p->fileName = p->fileName.mid(1); p->caseSensitivity=cs; } @@ -339,14 +341,22 @@ zipSetFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); else zipClearFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); - p->setZipError(zipOpenNewFileInZip3_64(p->zip->getZipFile(), - p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), &info_z, + p->setZipError(zipOpenNewFileInZip4_64(p->zip->getZipFile(), + p->zip->isUtf8Enabled() + ? info.name.toUtf8().constData() + : p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), + &info_z, info.extraLocal.constData(), info.extraLocal.length(), info.extraGlobal.constData(), info.extraGlobal.length(), - p->zip->getCommentCodec()->fromUnicode(info.comment).constData(), + p->zip->isUtf8Enabled() + ? info.comment.toUtf8().constData() + : p->zip->getCommentCodec()->fromUnicode(info.comment).constData(), method, level, (int)raw, windowBits, memLevel, strategy, - password, (uLong)crc, p->zip->isZip64Enabled())); + password, (uLong)crc, + (p->zip->getOsCode() << 8) | QUAZIP_VERSION_MADE_BY, + 0, + p->zip->isZip64Enabled())); if(p->zipError==UNZ_OK) { p->writePos=0; setOpenMode(mode); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazipnewinfo.cpp new/quazip-0.8.1/quazip/quazipnewinfo.cpp --- old/quazip-0.7.6/quazip/quazipnewinfo.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazipnewinfo.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -121,7 +121,7 @@ void QuaZipNewInfo::setPermissions(QFile::Permissions permissions) { - QuaZipNewInfo_setPermissions(this, permissions, name.endsWith('/')); + QuaZipNewInfo_setPermissions(this, permissions, name.endsWith(QLatin1String("/"))); } void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/quazipnewinfo.h new/quazip-0.8.1/quazip/quazipnewinfo.h --- old/quazip-0.7.6/quazip/quazipnewinfo.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/quazipnewinfo.h 2019-05-27 06:27:44.000000000 +0200 @@ -70,7 +70,7 @@ */ quint32 externalAttr; /// File comment. - /** Will be encoded using QuaZip::getCommentCodec(). + /** Will be encoded in UTF-8 encoding. **/ QString comment; /// File local extra field. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/unzip.c new/quazip-0.8.1/quazip/unzip.c --- old/quazip-0.7.6/quazip/unzip.c 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/unzip.c 2019-05-27 06:27:44.000000000 +0200 @@ -73,7 +73,7 @@ #include <stdlib.h> #include <string.h> -#include "zlib.h" +#include <zlib.h> #if (ZLIB_VERNUM < 0x1270) typedef uLongf z_crc_t; #endif @@ -858,6 +858,17 @@ pglobal_info32->size_comment = s->gi.size_comment; return UNZ_OK; } + +extern int ZEXPORT unzGetFileFlags (unzFile file, unsigned* pflags) +{ + unz64_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + *pflags = s->flags; + return UNZ_OK; +} + /* Translate date/time from Dos format to tm_unz (readable more easilty) */ @@ -1200,6 +1211,8 @@ &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); + if (s->cur_file_info.flag & UNZ_ENCODING_UTF8) + unzSetFlags(file, UNZ_ENCODING_UTF8); return err; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/unzip.h new/quazip-0.8.1/quazip/unzip.h --- old/quazip-0.7.6/quazip/unzip.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/unzip.h 2019-05-27 06:27:44.000000000 +0200 @@ -53,7 +53,7 @@ #endif #ifndef _ZLIB_H -#include "zlib.h" +#include <zlib.h> #endif #ifndef _ZLIBIOAPI_H @@ -87,6 +87,7 @@ #define UNZ_AUTO_CLOSE 0x01u #define UNZ_DEFAULT_FLAGS UNZ_AUTO_CLOSE +#define UNZ_ENCODING_UTF8 0x0800u /* tm_unz contain date/time info */ typedef struct tm_unz_s @@ -227,6 +228,8 @@ extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, unz_global_info64 *pglobal_info)); + +extern int ZEXPORT unzGetFileFlags OF((unzFile file, unsigned* pflags)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/zip.c new/quazip-0.8.1/quazip/zip.c --- old/quazip-0.7.6/quazip/zip.c 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/zip.c 2019-05-27 06:27:44.000000000 +0200 @@ -32,7 +32,8 @@ #include <stdlib.h> #include <string.h> #include <time.h> -#include "zlib.h" + +#include <zlib.h> #if (ZLIB_VERNUM < 0x1270) typedef uLongf z_crc_t; #endif @@ -992,7 +993,9 @@ if (err==ZIP_OK) { - if(zi->ci.zip64) + if(zi->ci.flag & ZIP_ENCODING_UTF8) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)63,2);/* Version 6.3 is required for Unicode support */ + else if(zi->ci.zip64) err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ else err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)version_to_extract,2); @@ -1150,6 +1153,8 @@ } zi->ci.flag = flagBase; + if (zi->flags & ZIP_ENCODING_UTF8) + zi->ci.flag |= ZIP_ENCODING_UTF8; if ((level==8) || (level==9)) zi->ci.flag |= 2; if (level==2) @@ -1655,8 +1660,7 @@ /*version Made by*/ zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); /*version needed*/ - zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2); - + zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2); } zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ @@ -1850,7 +1854,7 @@ err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); if (err==ZIP_OK) /* version needed */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2); if (err==ZIP_OK) /* number of this disk */ err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/quazip/zip.h new/quazip-0.8.1/quazip/zip.h --- old/quazip-0.7.6/quazip/zip.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/quazip/zip.h 2019-05-27 06:27:44.000000000 +0200 @@ -53,7 +53,7 @@ //#define HAVE_BZIP2 #ifndef _ZLIB_H -#include "zlib.h" +#include <zlib.h> #endif #ifndef _ZLIBIOAPI_H @@ -85,6 +85,7 @@ #define ZIP_WRITE_DATA_DESCRIPTOR 0x8u #define ZIP_AUTO_CLOSE 0x1u #define ZIP_SEQUENTIAL 0x2u +#define ZIP_ENCODING_UTF8 0x0800u #define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR) #ifndef DEF_MEM_LEVEL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/qztest/testquaziodevice.cpp new/quazip-0.8.1/qztest/testquaziodevice.cpp --- old/quazip-0.7.6/qztest/testquaziodevice.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/qztest/testquaziodevice.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -102,7 +102,8 @@ char outBuf[5]; zins.next_out = reinterpret_cast<Bytef*>(outBuf); zins.avail_out = 5; - inflate(&zins, Z_FINISH); + int result = inflate(&zins, Z_FINISH); + QCOMPARE(result, Z_STREAM_END); inflateEnd(&zins); int size = 5 - zins.avail_out; QCOMPARE(size, 4); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/qztest/testquazip.cpp new/quazip-0.8.1/qztest/testquazip.cpp --- old/quazip-0.7.6/qztest/testquazip.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/qztest/testquazip.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -208,6 +208,34 @@ curDir.remove(zipName); } +void TestQuaZip::setOsCode_data() +{ + QTest::addColumn<QString>("zipName"); + QTest::addColumn<uint>("osCode"); + QTest::newRow("unix") << "unix.zip" << 3u; + QTest::newRow("dos") << "dos.zip" << 0u; +} + +void TestQuaZip::setOsCode() +{ + QFETCH(QString, zipName); + QFETCH(uint, osCode); + QuaZip testZip(zipName); + testZip.setOsCode(osCode); + testZip.open(QuaZip::mdCreate); + QCOMPARE(testZip.getOsCode(), osCode); + QuaZipFile testZipFile(&testZip); + testZipFile.open(QIODevice::WriteOnly, QuaZipNewInfo("test.txt")); + testZipFile.close(); + testZip.close(); + QuaZip checkZip(zipName); + checkZip.open(QuaZip::mdUnzip); + checkZip.goToFirstFile(); + QuaZipFileInfo64 fi; + QVERIFY(checkZip.getCurrentFileInfo(&fi)); + QCOMPARE(fi.versionCreated >> 8, static_cast<quint16>(osCode)); +} + void TestQuaZip::setDataDescriptorWritingEnabled() { QString zipName = "zip10.zip"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/qztest/testquazip.h new/quazip-0.8.1/qztest/testquazip.h --- old/quazip-0.7.6/qztest/testquazip.h 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/qztest/testquazip.h 2019-05-27 06:27:44.000000000 +0200 @@ -40,6 +40,8 @@ void add(); void setFileNameCodec_data(); void setFileNameCodec(); + void setOsCode_data(); + void setOsCode(); void setDataDescriptorWritingEnabled(); void testQIODeviceAPI(); void setZipName(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quazip-0.7.6/qztest/testquazipfile.cpp new/quazip-0.8.1/qztest/testquazipfile.cpp --- old/quazip-0.7.6/qztest/testquazipfile.cpp 2018-06-13 17:51:21.000000000 +0200 +++ new/quazip-0.8.1/qztest/testquazipfile.cpp 2019-05-27 06:27:44.000000000 +0200 @@ -43,24 +43,32 @@ QTest::addColumn<QByteArray>("fileNameCodec"); QTest::addColumn<QByteArray>("password"); QTest::addColumn<bool>("zip64"); + QTest::addColumn<bool>("utf8"); QTest::addColumn<int>("size"); QTest::newRow("simple") << "simple.zip" << ( QStringList() << "test0.txt" << "testdir1/test1.txt" << "testdir2/test2.txt" << "testdir2/subdir/test2sub.txt") - << QByteArray() << QByteArray() << false << -1; + << QByteArray() << QByteArray() << false << false << -1; QTest::newRow("Cyrillic") << "cyrillic.zip" << ( QStringList() << QString::fromUtf8("русское имя файла с пробелами.txt")) - << QByteArray("IBM866") << QByteArray() << false << -1; + << QByteArray("IBM866") << QByteArray() << false << false << -1; + QTest::newRow("Unicode") << "unicode.zip" << ( + QStringList() + << QString::fromUtf8("Українське сало.txt") + << QString::fromUtf8("Vin français.txt") + << QString::fromUtf8("日本の寿司.txt") + << QString::fromUtf8("ქართული ხაჭაპური.txt")) + << QByteArray("") << QByteArray() << false << true << -1; QTest::newRow("password") << "password.zip" << ( QStringList() << "test.txt") - << QByteArray() << QByteArray("PassPass") << false << -1; + << QByteArray() << QByteArray("PassPass") << false << false << -1; QTest::newRow("zip64") << "zip64.zip" << ( QStringList() << "test64.txt") - << QByteArray() << QByteArray() << true << -1; + << QByteArray() << QByteArray() << true << false << -1; QTest::newRow("large enough to flush") << "flush.zip" << ( QStringList() << "flush.txt") - << QByteArray() << QByteArray() << true << 65536 * 2; + << QByteArray() << QByteArray() << true << false << 65536 * 2; } void TestQuaZipFile::zipUnzip() @@ -70,6 +78,7 @@ QFETCH(QByteArray, fileNameCodec); QFETCH(QByteArray, password); QFETCH(bool, zip64); + QFETCH(bool, utf8); QFETCH(int, size); QFile testFile(zipName); if (testFile.exists()) { @@ -82,10 +91,11 @@ } QuaZip testZip(&testFile); testZip.setZip64Enabled(zip64); + testZip.setUtf8Enabled(utf8); if (!fileNameCodec.isEmpty()) testZip.setFileNameCodec(fileNameCodec); QVERIFY(testZip.open(QuaZip::mdCreate)); - QString comment = "Test comment"; + QString comment = utf8 ? "test テスト ჩეკი" : "Test comment"; testZip.setComment(comment); foreach (QString fileName, fileNames) { QFile inFile("tmp/" + fileName);
