From: Christian Kamm Date: Thu, 15 Oct 2015 12:57:06 +0000 (+0200) Subject: ETag: Allow parsing of weak tags #3946 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1555 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=abd63035c1ca3dc59906cb24d10f4dc4fdd6213e;p=nextcloud-desktop.git ETag: Allow parsing of weak tags #3946 --- diff --git a/src/libsync/owncloudpropagator_p.h b/src/libsync/owncloudpropagator_p.h index aa1aa1cb9..3b188a2ef 100644 --- a/src/libsync/owncloudpropagator_p.h +++ b/src/libsync/owncloudpropagator_p.h @@ -25,7 +25,14 @@ inline QByteArray parseEtag(const char *header) { if (!header) return QByteArray(); QByteArray arr = header; - arr.replace("-gzip", ""); // https://github.comowncloud/client/issues/1195 + + // Weak E-Tags can appear when gzip compression is on, see #3946 + if (arr.startsWith("W/")) + arr = arr.mid(2); + + // https://github.com/owncloud/client/issues/1195 + arr.replace("-gzip", ""); + if(arr.length() >= 2 && arr.startsWith('"') && arr.endsWith('"')) { arr = arr.mid(1, arr.length() - 2); } diff --git a/test/testowncloudpropagator.h b/test/testowncloudpropagator.h index 24cdcdcd6..2347135d8 100644 --- a/test/testowncloudpropagator.h +++ b/test/testowncloudpropagator.h @@ -11,6 +11,7 @@ #include #include "propagatedownload.h" +#include "owncloudpropagator_p.h" using namespace OCC; namespace OCC { @@ -64,6 +65,20 @@ private slots: QVERIFY( tmpFileName.length() <= 254); } } + + void testParseEtag() + { + typedef QPair Test; + QList tests; + tests.append(Test("\"abcd\"", "abcd")); + tests.append(Test("\"\"", "")); + tests.append(Test("\"fii\"-gzip", "fii")); + tests.append(Test("W/\"foo\"", "foo")); + + foreach (const auto& test, tests) { + QCOMPARE(parseEtag(test.first), test.second); + } + } }; #endif