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

QNetworkReply returns incomplete data when returned data has wide characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.13.1, 5.14.0 Alpha
    • 5.13.0 RC 1
    • Network
    • None
    • WebAssembly
    • 570fb55a334d77959ed158fc55ac66814bd33f15 (qt/qtbase/5.13)

    Description

      In  q_loadCallback(val event) :

      if (readyState == 4) { // done
          reply->setReplyAttributes(xhr["data-handler"].as<quintptr>(), status, statusText);
          if (!responseString.isEmpty())
              reply->dataReceived( responseString.toUtf8(), responseString.size());
      }
      

      Actually, responseString.toUtf8() may have a different size than responseString if there are some Unicode characters in responseString. so we need to pass the size of the array, not the string itself. Here is the fix:

      if (readyState == 4) { // done
          reply->setReplyAttributes(xhr["data-handler"].as<quintptr>(), status, statusText);
          if (!responseString.isEmpty())
          {
              QByteArray responseStringArray = responseString.toUtf8();
              reply->dataReceived(responseStringArray, responseStringArray.size());
          }
      }
      

       

      Attachments

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

        Activity

          People

            lpotter Lorn Potter
            soheilarmin Soheil Armin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes