[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [messagelib] webengineviewer/src/checkphishingurl: Add missing code
From: Montel Laurent <montel () kde ! org>
Date: 2016-12-08 6:34:55
Message-ID: E1cEsIB-0003f1-44 () code ! kde ! org
[Download RAW message or body]
Git commit 4ed531cfa82cc44cdb6ac244c8568b8f4f5fcf65 by Montel Laurent.
Committed on 08/12/2016 at 06:32.
Pushed by mlaurent into branch 'master'.
Add missing code
M +85 -5 webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp
https://commits.kde.org/messagelib/4ed531cfa82cc44cdb6ac244c8568b8f4f5fcf65
diff --git a/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp \
b/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp index \
9e441821..77da88bd 100644
--- a/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp
+++ b/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp
@@ -22,6 +22,12 @@
#include "riceencodingdecoder.h"
#include "webengineviewer_debug.h"
+namespace
+{
+const int kBitsPerByte = 8;
+const unsigned int kMaxBitIndex = kBitsPerByte * sizeof(uint32_t);
+}
+
using namespace WebEngineViewer;
RiceEncodingDecoder::RiceEncodingDecoder()
{
@@ -77,18 +83,92 @@ QList<int> RiceEncodingDecoder::decodeRiceIndiceDelta(const \
RiceDeltaEncoding &r
QByteArray RiceEncodingDecoder::decodeRiceHashesDelta(const RiceDeltaEncoding \
&riceDeltaEncoding) {
+#if 0
QList<int> list;
list.reserve(riceDeltaEncoding.numberEntries + 1);
+ RiceDecoder decoder(riceDeltaEncoding.riceParameter, \
riceDeltaEncoding.numberEntries, riceDeltaEncoding.encodingData); + int \
lastValue(firstValue); + bool result = false;
+ list << htonl(lastValue);
+
+ while (decoder.hasOtherEntries()) {
+ uint32_t offset;
+ result = decoder.nextValue(&offset);
+ if (!result) {
+ return false;
+ }
+
+ lastValue += offset;
+#if 0
+ if (!last_value) {
+ return false;
+ }
+#endif
+ // This flipping is done so that the decoded uint32 is interpreted
+ // correcly as a string of 4 bytes.
+ list << htonl(lastValue);
+ }
+
+ // Flipping the bytes, as done above, destroys the sort order. Sort the
+ // values back.
+ std::sort(out->begin(), out->end());
+
+ QByteArray ba;
+ // This flipping is done so that when the vector is interpreted as a string,
+ // the bytes are in the correct order.
+ for (size_t i = 0; i < out->size(); i++) {
+ (*out)[i] = ntohl((*out)[i]);
+ }
+
+#if 0
+ V4DecodeResult result =
+ ValidateInput(rice_parameter, num_entries, encoded_data);
+ if (result != DECODE_SUCCESS) {
+ return result;
+ }
+ out->reserve((num_entries + 1));
+
+ base::CheckedNumeric<uint32_t> last_value(first_value);
+ out->push_back(htonl(last_value.ValueOrDie()));
+
+ if (num_entries > 0) {
+ V4RiceDecoder decoder(rice_parameter, num_entries, encoded_data);
+ while (decoder.HasAnotherValue()) {
+ uint32_t offset;
+ result = decoder.GetNextValue(&offset);
+ if (result != DECODE_SUCCESS) {
+ return result;
+ }
+
+ last_value += offset;
+ if (!last_value.IsValid()) {
+ NOTREACHED();
+ return DECODED_INTEGER_OVERFLOW_FAILURE;
+ }
+
+ // This flipping is done so that the decoded uint32 is interpreted
+ // correcly as a string of 4 bytes.
+ out->push_back(htonl(last_value.ValueOrDie()));
+ }
+ }
+
+ // Flipping the bytes, as done above, destroys the sort order. Sort the
+ // values back.
+ std::sort(out->begin(), out->end());
+
+ // This flipping is done so that when the vector is interpreted as a string,
+ // the bytes are in the correct order.
+ for (size_t i = 0; i < out->size(); i++) {
+ (*out)[i] = ntohl((*out)[i]);
+ }
+
+#endif
//TODO
+#endif
QByteArray ba;
return ba;
}
-namespace {
-const int kBitsPerByte = 8;
-const unsigned int kMaxBitIndex = kBitsPerByte * sizeof(uint32_t);
-}
-
RiceDecoder::RiceDecoder(int riceParameter, int numberEntries, const QByteArray& \
encodingData) : mEncodingData(encodingData),
mRiceParameter(riceParameter),
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic