aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-30 16:10:17 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-30 16:10:17 +0100
commitd5b4433c44f99bb30a6282c247de3938f3f8c987 (patch)
tree0a3f68a5d0fea8050d25da4a837107ae5700de27 /src/webengine
parentAdd smolbote.5 manpage (diff)
downloadsmolbote-d5b4433c44f99bb30a6282c247de3938f3f8c987.tar.xz
Fix filter.header not working
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/filter.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/webengine/filter.cpp b/src/webengine/filter.cpp
index 6941ac4..f1a38af 100644
--- a/src/webengine/filter.cpp
+++ b/src/webengine/filter.cpp
@@ -15,37 +15,20 @@
#include <QJsonDocument>
#include <QTextStream>
-/*
-inline std::vector<FilterRule> parseAdBlockList(const QString &filename)
-{
- std::vector<FilterRule> rules;
- QFile list(filename);
-
- if(list.open(QIODevice::ReadOnly | QIODevice::Text), true) {
- QTextStream l(&list);
- QString line;
- while(l.readLineInto(&line)) {
- AdBlockRule rule(line);
- if(rule.isEnabled()) {
- rules.emplace_back(std::move(rule));
- }
- }
- list.close();
- }
-
- return rules;
-}*/
-
Filter::Filter::Filter(const std::unique_ptr<Configuration> &config, QObject *parent)
: QObject(parent)
{
// parse headers
- if(const auto headers = config->value<QStringList>("filter.header"); headers) {
- for(const QString &header : headers.value()) {
+ if(config->exists("filter.header")) {
+ const auto headers = config->value<QStringList>("filter.header").value();
+ for(const QString header : headers) {
const auto list = header.split(QLatin1Literal(":"));
if(list.length() == 2)
m_headers.insert(list.at(0).toLatin1(), list.at(1).toLatin1());
}
+#ifdef QT_DEBUG
+ qDebug("Added %i custom http headers", m_headers.size());
+#endif
}
const QStringList hostfiles = Util::files(config->value<QString>("filter.hosts").value());
@@ -60,12 +43,6 @@ Filter::Filter::Filter(const std::unique_ptr<Configuration> &config, QObject *pa
f.close();
}
}
-
- /*
- auto filtersPath = config->value<QString>("filter.adblock");
- if(filtersPath)
- filters = parseAdBlockList(filtersPath.value());
- */
}
void Filter::filterRequest(QWebEngineUrlRequestInfo &info) const