aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/smolbote.5.asciidoc7
-rw-r--r--include/profileinterface.h4
-rw-r--r--lib/configuration/configuration.h7
-rw-r--r--src/webengine/filter.cpp35
4 files changed, 17 insertions, 36 deletions
diff --git a/doc/smolbote.5.asciidoc b/doc/smolbote.5.asciidoc
index 6b48def..5b17a36 100644
--- a/doc/smolbote.5.asciidoc
+++ b/doc/smolbote.5.asciidoc
@@ -17,6 +17,9 @@ The settings in this file change your preferences and keybindings.
Lines starting with *#* are considered comments and ignored.
+Options taking multiple values (list options) can have multiple values set by
+using the same option name multiple times.
+
== Sections
=== Browser Options
@@ -90,11 +93,11 @@ Show/Hide downloads widget shortcut.
*subwindow.shortcuts.moveRight* (arg=Ctrl+Shift+P):: Move tab to the right
*subwindow.shortcuts.fullscreen* (arg=F11):: Show page fullscreen
-=== Secutiry Options
+=== Security Options
*filter.hosts* (arg=~/.config/smolbote/hosts.d):: Hostlist
*filter.adblock* arg:: TODO
-*filter.header* arg::
+*filter.header* (list)::
A list of HTTP headers to set. Each header should be given as a colon-separated
name:value pair.
diff --git a/include/profileinterface.h b/include/profileinterface.h
index c24a4ae..e25b085 100644
--- a/include/profileinterface.h
+++ b/include/profileinterface.h
@@ -36,8 +36,8 @@ class Profile : public QWebEngineProfile
Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY propertyChanged)
protected:
- explicit Profile(QObject *parent = nullptr) : QWebEngineProfile(parent) {};
- explicit Profile(const QString &storageName, QObject *parent = nullptr) : QWebEngineProfile(storageName, parent) {};
+ explicit Profile(QObject *parent = nullptr) : QWebEngineProfile(parent) {}
+ explicit Profile(const QString &storageName, QObject *parent = nullptr) : QWebEngineProfile(storageName, parent) {}
public:
virtual const QString name() const = 0;
diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h
index 4f9eafd..2bdd2c5 100644
--- a/lib/configuration/configuration.h
+++ b/lib/configuration/configuration.h
@@ -44,13 +44,14 @@ public:
return std::nullopt;
}
+ // path is guaranteed to exist, so using vm[path] is safe
+
if constexpr(std::is_same_v<T, QString>) {
- return std::optional<QString>(QString::fromStdString(this->value<std::string>(path).value()));
- //return std::optional<QString>(vm[path].as<const char*>());
+ return std::optional<QString>(QString::fromStdString(vm[path].as<std::string>()));
} else if constexpr(std::is_same_v<T, QStringList>) {
QStringList r;
- for(const std::string &item : this->value<std::vector<std::string>>(path).value()) {
+ for(const std::string &item : vm[path].as<std::vector<std::string>>()) {
r.append(QString::fromStdString(item));
}
return std::optional<QStringList>(r);
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