summaryrefslogtreecommitdiffstats
path: root/src/webview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 9ebc1ba..4fb8511 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -1,6 +1,7 @@
#include "webview.h"
#include "nam.h"
#include "global.h"
+#include "settings.h"
#include <QWebFrame>
#include <QNetworkReply>
@@ -14,6 +15,7 @@
#include <QWebElement>
#include <QRegularExpression>
#include <QWebPage>
+#include <QWebFrame>
static QRegularExpression urlListToRegExp(const QStringList &list);
@@ -32,13 +34,21 @@ QRegularExpression UaWebPage::re("(\\S+)$");
WebView::WebView(QWidget* parent)
: QWebView(parent),
- _timerAbortMessage(new QTimer(this)),
- _abortedDownload(false),
- _inErrorState(false),
- _timerReset(new QTimer(this)),
- _firstLoad(false)
+ _timerAbortMessage(new QTimer(this)),
+ _abortedDownload(false),
+ _inErrorState(false),
+ _timerReset(new QTimer(this)),
+ _firstLoad(false)
{
- this->setPage(new UaWebPage);
+ auto p = new UaWebPage;
+ if (!Settings::allowedShibbolethDomains().trimmed().isEmpty()) {
+ QObject::connect(p, &UaWebPage::frameCreated, [this](QWebFrame *frame) {
+ QObject::connect(frame, &QWebFrame::javaScriptWindowObjectCleared, [this, frame]() {
+ this->jsInjector(frame);
+ });
+ });
+ }
+ this->setPage(p);
_timerAbortMessage->setSingleShot(true);
_timerReset->setSingleShot(true);
connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
@@ -60,6 +70,14 @@ WebView::WebView(QWidget* parent)
connect(this, &QWebView::loadFinished, this, &WebView::onLoadFinished);
}
+void WebView::jsInjector(QWebFrame *frame)
+{
+ QString str = Settings::allowedShibbolethDomains().replace(
+ QRegularExpression("[^\\w. -]", QRegularExpression::UseUnicodePropertiesOption),
+ QStringLiteral(""));
+ frame->evaluateJavaScript(QStringLiteral("var slxIdpFilter ='") + str + QStringLiteral("'"));
+}
+
void WebView::windowCloseRequested()
{
// If we have an old URL stored on the stack, navigate back to it, otherwise we return and nothing happens