Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94157

QZip Decompression has problems with Chinese processing (was: QZip 解压缩对中文处理有问题)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P4: Low
    • None
    • 5.7.1, 6.0.0
    • Core: I/O
    • None
    • Qt5.7.1, I checked Qt6, the problem still exists
    • Windows

    Description

      File location:Src\qtbase\src\gui\text\Qzip.cpp

      Problem function:fileData,The two functions of QZipWriter::addFile and QZipReader::fileData handle file encodings that are inconsistent

      Normal special case: it is normal when the codec is set to utf8, and the result of fromLocal8Bit is consistent with fromUtf8

      The suspected code, at line 935:

      QByteArray QZipReader::fileData(const QString &fileName) const
      {
      d->scanFiles();
      int i;
      for (i = 0; i < d->fileHeaders.size(); ++i) {
      if (QString::fromLocal8Bit(d->fileHeaders.at.file_name) == fileName)
      break;
      }
      if (i == d->fileHeaders.size())
      return QByteArray();

      ........

      }

      Modified code:

      QByteArray QZipReader::fileData(const QString &fileName) const
      {
      d->scanFiles();
      int i;
      for (i = 0; i < d->fileHeaders.size(); ++i) {
      FileHeader header=d->fileHeaders.at;
      ushort general_purpose_bits = readUShort(header.h.general_purpose_bits);
      const bool inUtf8 = (general_purpose_bits & Utf8Names) != 0;
      QString file_name= inUtf8 ? QString::fromUtf8(header.file_name) : QString::fromLocal8Bit(header.file_name);
      if (file_name == fileName)
      break;
      }
      if (i == d->fileHeaders.size())
      return QByteArray();

      .......

      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            afeng huang weifeng
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Gerrit Reviews

                  There are no open Gerrit changes