From 18ab4f2a7b24d27becb5ed91fe952f8623741941 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Sun, 17 Jul 2016 01:31:25 -0600 Subject: [PATCH 1/7] GM WIN: Add CR to detection (#2027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIN: Add CR to detection Saving in Notepad++ with Windows line ending prevents script injection Post fix for #1964 and some vague references at https://github.com/QupZilla/qupzilla/commit/ce67c7a455a58b3cf64491054688e4c9e9593c3a * Add some more line ending checks * Windows ends in CR and OS Ⅸ compatible uses CR+LF ... OS Ⅹ/*nix uses LF * Fix pre-existing bug with `\n' with string split for Windows ... tested only on Linux *(Qt 5.6.1)* with Unit Tests so far Applies to #2027 and post followup for #1964 * Use default Left-associative for pipe (logical or) * Specific first then general after e.g. flip them ... helps avoid a false injection match with a control character at the beginning with older editors *(may include OS2)* Applies to #2027 and post followup for #1964 --- src/plugins/GreaseMonkey/gm_script.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/GreaseMonkey/gm_script.cpp b/src/plugins/GreaseMonkey/gm_script.cpp index 4a44d402c..066d1e958 100644 --- a/src/plugins/GreaseMonkey/gm_script.cpp +++ b/src/plugins/GreaseMonkey/gm_script.cpp @@ -238,7 +238,7 @@ void GM_Script::parseScript() const QString fileData = QString::fromUtf8(file.readAll()); - QzRegExp rx(QSL("(?:^|\\n)// ==UserScript==(.*)\\n// ==/UserScript==(?:\\n|$)")); + QzRegExp rx(QSL("(?:^|[\\r\\n])// ==UserScript==(.*)(?:\\r\\n|[\\r\\n])// ==/UserScript==(?:[\\r\\n]|$)")); rx.indexIn(fileData); QString metadataBlock = rx.cap(1).trimmed(); @@ -248,8 +248,9 @@ void GM_Script::parseScript() } QStringList requireList; + QzRegExp rxNL(QSL("(?:\\r\\n|[\\r\\n])")); - const QStringList lines = metadataBlock.split(QLatin1Char('\n'), QString::SkipEmptyParts); + const QStringList lines = metadataBlock.split(rxNL, QString::SkipEmptyParts); foreach (QString line, lines) { if (!line.startsWith(QLatin1String("// @"))) { continue; From 757c6525f5a8e311d7bbb049bdb488a944947498 Mon Sep 17 00:00:00 2001 From: spaeps Date: Mon, 25 Jul 2016 10:24:49 +0200 Subject: [PATCH 2/7] Add short command line for all options (#2036) --- src/lib/app/commandlineoptions.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/app/commandlineoptions.cpp b/src/lib/app/commandlineoptions.cpp index a188d11b5..6dd4fd596 100644 --- a/src/lib/app/commandlineoptions.cpp +++ b/src/lib/app/commandlineoptions.cpp @@ -43,36 +43,36 @@ void CommandLineOptions::parseActions() profileOption.setValueName(QSL("profileName")); profileOption.setDescription(QSL("Starts with specified profile.")); - QCommandLineOption noExtensionsOption(QSL("no-extensions")); + QCommandLineOption noExtensionsOption(QStringList({QSL("e"), QSL("no-extensions")})); noExtensionsOption.setDescription(QSL("Starts without extensions.")); - QCommandLineOption privateBrowsingOption(QSL("private-browsing")); + QCommandLineOption privateBrowsingOption(QStringList({QSL("i"), QSL("private-browsing")})); privateBrowsingOption.setDescription(QSL("Starts private browsing.")); - QCommandLineOption portableOption(QSL("portable")); + QCommandLineOption portableOption(QStringList({QSL("o"), QSL("portable")})); portableOption.setDescription(QSL("Starts in portable mode.")); - QCommandLineOption noRemoteOption(QSL("no-remote")); + QCommandLineOption noRemoteOption(QStringList({QSL("r"), QSL("no-remote")})); noRemoteOption.setDescription(QSL("Starts new browser instance.")); - QCommandLineOption newTabOption(QSL("new-tab")); + QCommandLineOption newTabOption(QStringList({QSL("t"), QSL("new-tab")})); newTabOption.setDescription(QSL("Opens new tab.")); - QCommandLineOption newWindowOption(QSL("new-window")); + QCommandLineOption newWindowOption(QStringList({QSL("w"), QSL("new-window")})); newWindowOption.setDescription(QSL("Opens new window.")); - QCommandLineOption downloadManagerOption(QSL("download-manager")); + QCommandLineOption downloadManagerOption(QStringList({QSL("d"), QSL("download-manager")})); downloadManagerOption.setDescription(QSL("Opens download manager.")); - QCommandLineOption currentTabOption(QSL("current-tab")); + QCommandLineOption currentTabOption(QStringList({QSL("c"), QSL("current-tab")})); currentTabOption.setValueName(QSL("URL")); currentTabOption.setDescription(QSL("Opens URL in current tab.")); - QCommandLineOption openWindowOption(QSL("open-window")); + QCommandLineOption openWindowOption(QStringList({QSL("u"), QSL("open-window")})); openWindowOption.setValueName(QSL("URL")); openWindowOption.setDescription(QSL("Opens URL in new window.")); - QCommandLineOption fullscreenOption(QSL("fullscreen")); + QCommandLineOption fullscreenOption(QStringList({QSL("f"), QSL("fullscreen")})); fullscreenOption.setDescription(QSL("Toggles fullscreen.")); // Parser From 0e3448f96c2dfba8bcd2399266d5866ab74bd523 Mon Sep 17 00:00:00 2001 From: cranes-bill Date: Sun, 31 Jul 2016 15:35:02 +0300 Subject: [PATCH 3/7] Fix completions according to new options (#2043) --- linux/completion/_qupzilla | 22 +++++++++++----------- linux/completion/qupzilla | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/linux/completion/_qupzilla b/linux/completion/_qupzilla index 3e1406795..e1d023b71 100644 --- a/linux/completion/_qupzilla +++ b/linux/completion/_qupzilla @@ -7,18 +7,18 @@ opts=( '(-)'{-a,--authors}'[print QupZilla authors]' '(-)'{-v,--version}'[print QupZilla version]' - '(-)'{-p=,--profile=}'[start with specified profile]' - '(-)'{-ne,--no-extensions}'[start without extensions]' - '(-)'{-po,--portable}'[start in portable mode]' + '(-)'{-p,--profile=}'[start with specified profile]' + '(-)'{-e,--no-extensions}'[start without extensions]' + '(-)'{-o,--portable}'[start in portable mode]' - '(-)'{-nt,--new-tab}'[open new tab]' - '(-)'{-nw,--new-window}'[open new window]' - '(-)'{-pb,--private-browsing}'[start private browsing]' - '(-)'{-dm,--download-manager}'[show download manager]' - '(-)'{-fs,--fullscreen}'[toggle fullscreen]' - '(-)'{-nr,--no-remote}'[open new browser instance]' - '(-)'{-ct=,--current-tab=}'[open URL in current tab]' - '(-)'{-ow=,--open-window=}'[open URL in new window]' + '(-)'{-t,--new-tab}'[open new tab]' + '(-)'{-w,--new-window}'[open new window]' + '(-)'{-i,--private-browsing}'[start private browsing]' + '(-)'{-d,--download-manager}'[show download manager]' + '(-)'{-f,--fullscreen}'[toggle fullscreen]' + '(-)'{-r,--no-remote}'[open new browser instance]' + '(-)'{-c,--current-tab=}'[open URL in current tab]' + '(-)'{-u,--open-window=}'[open URL in new window]' '*:files:_files' ) diff --git a/linux/completion/qupzilla b/linux/completion/qupzilla index 61410b0ba..2d2f95775 100644 --- a/linux/completion/qupzilla +++ b/linux/completion/qupzilla @@ -7,11 +7,11 @@ _qupzilla() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="-h --help -a --authors -v --version -p= --profile= - -ne --no-extensions -po --portable -nt --new-tab - -nw --new-window -pb --private-browsing -dm --download-manager - -fs --fullscreen -nr --no-remote -ct= --current-tab= - -ow= --open-window=" + opts="-h --help -a --authors -v --version -p --profile= + -e --no-extensions -o --portable -t --new-tab + -w --new-window -i --private-browsing -d --download-manager + -f --fullscreen -r --no-remote -c --current-tab= + -u --open-window=" if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) From 648090d16769992a69f4e60334de314ac7ac3c5b Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sun, 17 Jul 2016 09:38:01 +0200 Subject: [PATCH 4/7] Fix warning about converting double to int --- src/lib/tabwidget/tabicon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/tabwidget/tabicon.cpp b/src/lib/tabwidget/tabicon.cpp index 0460b0b48..feee640af 100644 --- a/src/lib/tabwidget/tabicon.cpp +++ b/src/lib/tabwidget/tabicon.cpp @@ -100,7 +100,7 @@ void TabIcon::paintEvent(QPaintEvent* event) QPainter p(this); const int size = 16; - const int pixmapSize = size * m_animationPixmap.devicePixelRatioF(); + const int pixmapSize = qRound(size * m_animationPixmap.devicePixelRatioF()); // Center the pixmap in rect QRect r = rect(); From 9ae6c12a3c849b41fb640a8d13c9c98e462500e9 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 15 Aug 2016 14:54:54 +0300 Subject: [PATCH 5/7] Show navigation in new tab in fullscreen mode (#2055) --- src/lib/app/browserwindow.cpp | 7 +++++++ src/lib/tabwidget/tabwidget.cpp | 16 ++++++++++++++++ src/lib/tabwidget/tabwidget.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index f863f7062..66fd5f0de 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -970,6 +970,10 @@ void BrowserWindow::removeActions(const QList &actions) void BrowserWindow::addTab() { m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true); + m_tabWidget->setCurrentTabFresh(true); + + if (isFullScreen()) + showNavigationWithFullScreen(); } void BrowserWindow::webSearch() @@ -1035,6 +1039,9 @@ void BrowserWindow::showNavigationWithFullScreen() void BrowserWindow::hideNavigationWithFullScreen() { + if (m_tabWidget->isCurrentTabFresh()) + return; + if (!m_hideNavigationTimer->isActive()) { m_hideNavigationTimer->start(); } diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index bfdcb8e8a..41dc4d008 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -230,6 +230,16 @@ void TabWidget::updateClosedTabsButton() m_buttonClosedTabs->setEnabled(canRestoreTab()); } +bool TabWidget::isCurrentTabFresh() const +{ + return m_currentTabFresh; +} + +void TabWidget::setCurrentTabFresh(bool currentTabFresh) +{ + m_currentTabFresh = currentTabFresh; +} + void TabWidget::tabBarOverFlowChanged(bool overflowed) { // Show buttons inside tabbar @@ -324,6 +334,7 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N { QUrl url = req.url(); m_lastTabIndex = currentIndex(); + m_currentTabFresh = false; if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) { url = m_urlOnNewTab; @@ -367,6 +378,10 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(webTab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); connect(webTab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); + connect(webTab->webView(), &WebView::urlChanged, this, [this](const QUrl &url) { + if (url != m_urlOnNewTab) + m_currentTabFresh = false; + }); if (url.isValid() && url != req.url()) { LoadRequest r(req); @@ -489,6 +504,7 @@ void TabWidget::currentTabChanged(int index) m_lastBackgroundTabIndex = -1; m_lastTabIndex = index; + m_currentTabFresh = false; WebTab* webTab = weTab(index); LocationBar* locBar = webTab->locationBar(); diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index 4d8a8fd61..467b9278f 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -93,6 +93,8 @@ public: ClosedTabsManager* closedTabsManager() const; QList allTabs(bool withPinned = true); bool canRestoreTab() const; + bool isCurrentTabFresh() const; + void setCurrentTabFresh(bool currentTabFresh); QStackedWidget* locationBars() const; ToolButton* buttonClosedTabs() const; @@ -164,6 +166,8 @@ private: bool m_newTabAfterActive; bool m_newEmptyTabAfterActive; QUrl m_urlOnNewTab; + + bool m_currentTabFresh; }; #endif // TABWIDGET_H From cce94944f71194bd64427211611b4c5b86a3f2be Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 15 Aug 2016 13:58:25 +0200 Subject: [PATCH 6/7] Don't hide supermenu button in fullscreen Also make the supermenu button as last button in toolbar --- src/lib/app/browserwindow.cpp | 1 - src/lib/navigation/navigationbar.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 66fd5f0de..0467d0407 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -1075,7 +1075,6 @@ bool BrowserWindow::event(QEvent* event) statusBar()->hide(); m_navigationContainer->hide(); - m_navigationToolbar->setSuperMenuVisible(false); m_navigationToolbar->buttonExitFullscreen()->setVisible(true); } else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) { diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index d79c9a4a2..b88b017ea 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2010-2016 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -133,8 +133,8 @@ NavigationBar::NavigationBar(BrowserWindow* window) m_layout->addWidget(m_buttonHome); m_layout->addWidget(m_buttonAddTab); m_layout->addWidget(m_navigationSplitter); - m_layout->addWidget(m_supMenu); m_layout->addWidget(m_exitFullscreen); + m_layout->addWidget(m_supMenu); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); From 42eadaeb2f86b72c2640ec82400dd5dbc0297f2f Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 15 Aug 2016 14:25:01 +0200 Subject: [PATCH 7/7] Fix scrolling to current tab when added from fullscreen mode --- src/lib/tabwidget/tabbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index f342977dc..157236027 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -433,7 +433,9 @@ void TabBar::currentTabChanged(int index) showCloseButton(index); hideCloseButton(m_tabWidget->lastTabIndex()); - ensureVisible(index); + QTimer::singleShot(0, this, [=]() { + ensureVisible(index); + }); } m_tabWidget->currentTabChanged(index);