From 279b0ba6c469421b420294340766622b9dfa890a Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 9 Mar 2022 19:00:49 +1000 Subject: [PATCH] wasm: fix issue with passing username/password to network request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The data scope was wrong, it needs to live beyond the attribute strut Change-Id: If1ceb4967fc1755d4968a69bcd9d82b234bd871d Done-with: Vincent Rouillé Fixes: QTBUG-101551 Pick-to: 6.3 6.2 5.15 Reviewed-by: Morten Johan Sørvig Reviewed-by: David Skoland --- src/network/access/qnetworkreplywasmimpl.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index d46c27e60a7..0aaaa17b152 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -234,10 +234,13 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() } } + QByteArray userName, password; // username & password if (!request.url().userInfo().isEmpty()) { - attr.userName = request.url().userName().toUtf8(); - attr.password = request.url().password().toUtf8(); + userName = request.url().userName().toUtf8(); + password = request.url().password().toUtf8(); + attr.userName = userName.constData(); + attr.password = password.constData(); } attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY; @@ -265,7 +268,8 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() attr.userData = reinterpret_cast(this); QString dPath = QStringLiteral("/home/web_user/") + request.url().fileName(); - attr.destinationPath = dPath.toUtf8(); + QByteArray destinationPath = dPath.toUtf8(); + attr.destinationPath = destinationPath.constData(); m_fetch = emscripten_fetch(&attr, request.url().toString().toUtf8()); }