[Pkg-owncloud-commits] [owncloud-client] 69/484: ETag: Allow parsing of weak tags #3946
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:14 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit abd63035c1ca3dc59906cb24d10f4dc4fdd6213e
Author: Christian Kamm <mail at ckamm.de>
Date: Thu Oct 15 14:57:06 2015 +0200
ETag: Allow parsing of weak tags #3946
---
src/libsync/owncloudpropagator_p.h | 9 ++++++++-
test/testowncloudpropagator.h | 15 +++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/libsync/owncloudpropagator_p.h b/src/libsync/owncloudpropagator_p.h
index aa1aa1c..3b188a2 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 24cdcdc..2347135 100644
--- a/test/testowncloudpropagator.h
+++ b/test/testowncloudpropagator.h
@@ -11,6 +11,7 @@
#include <QDebug>
#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<const char*, const char*> Test;
+ QList<Test> 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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list