From 43965eb877ed24d94b8cfa09f948b7877bcffc24 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 27 Oct 2020 13:23:01 +0100 Subject: Allow blacklist and whitelist at the same time. Whitelist takes precedence. --- src/main.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 6bd0897..2213913 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,8 +40,8 @@ int main(int argc, char** argv) QCommandLineOption fullscreen("fullscreen", "Run browser in full screen."); QCommandLineOption maximized("maximized", "Maximize window on startup"); QCommandLineOption reloadInterval("reload-interval", "Reload displayed page every X seconds.", "seconds"); - QCommandLineOption whitelist("whitelist", "Path to a file of allowed URLs. Mutually exclusive with blacklist.", "file"); - QCommandLineOption blacklist("blacklist", "Path to a file of disallowed URLs. Mutually exclusive with whitelist.", "file"); + QCommandLineOption whitelist("whitelist", "Path to a file of allowed URLs.", "file"); + QCommandLineOption blacklist("blacklist", "Path to a file of disallowed URLs.", "file"); parser.addOption(ignoreSsl); parser.addOption(fullscreen); parser.addOption(maximized); @@ -54,10 +54,6 @@ int main(int argc, char** argv) QMessageBox::critical(nullptr, "Error", "Need one argument: file name"); return 1; } - if (parser.isSet(whitelist) && parser.isSet(blacklist)) { - QMessageBox::critical(nullptr, "Error", "Need either blacklist or whitelist, not both"); - return 2; - } BrowserSettings settings; settings.url = list[0]; settings.fullscreen = parser.isSet(fullscreen); @@ -65,11 +61,11 @@ int main(int argc, char** argv) settings.ignoreSslErrors = parser.isSet(ignoreSsl); settings.reloadInterval = parser.value(reloadInterval).toInt(); if (parser.isSet(whitelist)) { - settings.urlList = loadUrlList(parser.value(whitelist)); - } else if (parser.isSet(blacklist)) { - settings.urlList = loadUrlList(parser.value(blacklist)); + settings.whiteList = loadUrlList(parser.value(whitelist)); + } + if (parser.isSet(blacklist)) { + settings.blackList = loadUrlList(parser.value(blacklist)); } - settings.isWhitelist = parser.isSet(whitelist); SlxBrowser main(settings); main.show(); app.installEventFilter(new KeyHandler(&main)); -- cgit v1.2.3-55-g7522