mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 02:52:12 +01:00
[Qt5] Use RegExp wrapper to take advantage of new regexp engine.
QzRegExp wrapper is using QRegExp directly on Qt 4 and QRegularExpression (with PCRE engine) on Qt 5.
This commit is contained in:
parent
f32ec93caf
commit
bed43ed0c8
|
@ -48,7 +48,7 @@
|
||||||
#include "adblocksubscription.h"
|
#include "adblocksubscription.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
@ -467,7 +467,7 @@ void AdBlockRule::parseFilter()
|
||||||
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
||||||
|
|
||||||
m_useRegExp = true;
|
m_useRegExp = true;
|
||||||
m_regExp = QRegExp(parsedLine, m_caseSensitivity, QRegExp::RegExp);
|
m_regExp = QzRegExp(parsedLine, m_caseSensitivity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ void AdBlockRule::parseFilter()
|
||||||
|
|
||||||
// We can use fast string matching for domain here
|
// We can use fast string matching for domain here
|
||||||
if (parsedLine.startsWith(QLatin1String("||")) && parsedLine.endsWith(QLatin1Char('^'))
|
if (parsedLine.startsWith(QLatin1String("||")) && parsedLine.endsWith(QLatin1Char('^'))
|
||||||
&& !parsedLine.contains(QRegExp("[/:?=&\\*]"))) {
|
&& !parsedLine.contains(QzRegExp("[/:?=&\\*]"))) {
|
||||||
parsedLine = parsedLine.mid(2);
|
parsedLine = parsedLine.mid(2);
|
||||||
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ void AdBlockRule::parseFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If rule contains only | at end, we can also use string matching
|
// If rule contains only | at end, we can also use string matching
|
||||||
if (parsedLine.endsWith(QLatin1Char('|')) && !parsedLine.contains(QRegExp("[\\^\\*]"))
|
if (parsedLine.endsWith(QLatin1Char('|')) && !parsedLine.contains(QzRegExp("[\\^\\*]"))
|
||||||
&& parsedLine.count(QLatin1Char('|')) == 1) {
|
&& parsedLine.count(QLatin1Char('|')) == 1) {
|
||||||
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
parsedLine = parsedLine.left(parsedLine.size() - 1);
|
||||||
|
|
||||||
|
@ -502,24 +502,24 @@ void AdBlockRule::parseFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we still find a wildcard (*) or separator (^) or (|)
|
// If we still find a wildcard (*) or separator (^) or (|)
|
||||||
// we must modify parsedLine to comply with QRegExp
|
// we must modify parsedLine to comply with QzRegExp
|
||||||
if (parsedLine.contains(QLatin1Char('*')) || parsedLine.contains(QLatin1Char('^'))
|
if (parsedLine.contains(QLatin1Char('*')) || parsedLine.contains(QLatin1Char('^'))
|
||||||
|| parsedLine.contains(QLatin1Char('|'))) {
|
|| parsedLine.contains(QLatin1Char('|'))) {
|
||||||
parsedLine.replace(QRegExp(QLatin1String("\\*+")), QLatin1String("*")) // remove multiple wildcards
|
parsedLine.replace(QzRegExp(QLatin1String("\\*+")), QLatin1String("*")) // remove multiple wildcards
|
||||||
.replace(QRegExp(QLatin1String("\\^\\|$")), QLatin1String("^")) // remove anchors following separator placeholder
|
.replace(QzRegExp(QLatin1String("\\^\\|$")), QLatin1String("^")) // remove anchors following separator placeholder
|
||||||
.replace(QRegExp(QLatin1String("^(\\*)")), QString()) // remove leading wildcards
|
.replace(QzRegExp(QLatin1String("^(\\*)")), QString()) // remove leading wildcards
|
||||||
.replace(QRegExp(QLatin1String("(\\*)$")), QString())
|
.replace(QzRegExp(QLatin1String("(\\*)$")), QString())
|
||||||
.replace(QRegExp(QLatin1String("(\\W)")), QLatin1String("\\\\1")) // escape special symbols
|
.replace(QzRegExp(QLatin1String("(\\W)")), QLatin1String("\\\\1")) // escape special symbols
|
||||||
.replace(QRegExp(QLatin1String("^\\\\\\|\\\\\\|")),
|
.replace(QzRegExp(QLatin1String("^\\\\\\|\\\\\\|")),
|
||||||
QLatin1String("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?")) // process extended anchor at expression start
|
QLatin1String("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?")) // process extended anchor at expression start
|
||||||
.replace(QRegExp(QLatin1String("\\\\\\^")),
|
.replace(QzRegExp(QLatin1String("\\\\\\^")),
|
||||||
QLatin1String("(?:[^\\w\\d\\-.%]|$)")) // process separator placeholders
|
QLatin1String("(?:[^\\w\\d\\-.%]|$)")) // process separator placeholders
|
||||||
.replace(QRegExp(QLatin1String("^\\\\\\|")), QLatin1String("^")) // process anchor at expression start
|
.replace(QzRegExp(QLatin1String("^\\\\\\|")), QLatin1String("^")) // process anchor at expression start
|
||||||
.replace(QRegExp(QLatin1String("\\\\\\|$")), QLatin1String("$")) // process anchor at expression end
|
.replace(QzRegExp(QLatin1String("\\\\\\|$")), QLatin1String("$")) // process anchor at expression end
|
||||||
.replace(QRegExp(QLatin1String("\\\\\\*")), QLatin1String(".*")); // replace wildcards by .*
|
.replace(QzRegExp(QLatin1String("\\\\\\*")), QLatin1String(".*")); // replace wildcards by .*
|
||||||
|
|
||||||
m_useRegExp = true;
|
m_useRegExp = true;
|
||||||
m_regExp = QRegExp(parsedLine, m_caseSensitivity, QRegExp::RegExp);
|
m_regExp = QzRegExp(parsedLine, m_caseSensitivity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,10 @@
|
||||||
#define ADBLOCKRULE_H
|
#define ADBLOCKRULE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRegExp>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
class QNetworkRequest;
|
class QNetworkRequest;
|
||||||
class QUrl;
|
class QUrl;
|
||||||
|
@ -111,7 +111,7 @@ private:
|
||||||
bool m_domainRestricted;
|
bool m_domainRestricted;
|
||||||
|
|
||||||
bool m_useRegExp;
|
bool m_useRegExp;
|
||||||
QRegExp m_regExp;
|
QzRegExp m_regExp;
|
||||||
|
|
||||||
bool m_useDomainMatch;
|
bool m_useDomainMatch;
|
||||||
bool m_useEndsMatch;
|
bool m_useEndsMatch;
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "useragentmanager.h"
|
#include "useragentmanager.h"
|
||||||
#include "restoremanager.h"
|
#include "restoremanager.h"
|
||||||
#include "proxystyle.h"
|
#include "proxystyle.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
#include "checkboxdialog.h"
|
#include "checkboxdialog.h"
|
||||||
#include "registerqappassociation.h"
|
#include "registerqappassociation.h"
|
||||||
#include "html5permissions/html5permissionsmanager.h"
|
#include "html5permissions/html5permissionsmanager.h"
|
||||||
|
@ -375,7 +376,7 @@ void MainApplication::loadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString relativePath = QDir::current().relativeFilePath(m_activeThemePath);
|
QString relativePath = QDir::current().relativeFilePath(m_activeThemePath);
|
||||||
css.replace(QRegExp("url\\s*\\(\\s*([^\\*:\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
|
css.replace(QzRegExp("url\\s*\\(\\s*([^\\*:\\);]+)\\s*\\)", Qt::CaseSensitive),
|
||||||
QString("url(%1\\1)").arg(relativePath + "/"));
|
QString("url(%1\\1)").arg(relativePath + "/"));
|
||||||
setStyleSheet(css);
|
setStyleSheet(css);
|
||||||
|
|
||||||
|
|
|
@ -1732,7 +1732,7 @@ void QupZilla::hideNavigationWithFullScreen()
|
||||||
void QupZilla::hideNavigationSlot()
|
void QupZilla::hideNavigationSlot()
|
||||||
{
|
{
|
||||||
TabbedWebView* view = weView();
|
TabbedWebView* view = weView();
|
||||||
bool mouseInView = view && view->geometry().contains(view->mapFromGlobal(QCursor::pos()));
|
bool mouseInView = view && view->underMouse();
|
||||||
|
|
||||||
if (isFullScreen() && mouseInView) {
|
if (isFullScreen() && mouseInView) {
|
||||||
m_navigationContainer->hide();
|
m_navigationContainer->hide();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "pageformcompleter.h"
|
#include "pageformcompleter.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
#include <QWebPage>
|
#include <QWebPage>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
|
@ -160,7 +161,7 @@ QByteArray PageFormCompleter::convertWebKitFormBoundaryIfNecessary(const QByteAr
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray formatedData;
|
QByteArray formatedData;
|
||||||
QRegExp rx("name=\"(.*)------WebKitFormBoundary");
|
QzRegExp rx("name=\"(.*)------WebKitFormBoundary");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
#include <QScriptValueIterator>
|
#include <QScriptValueIterator>
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
|
|
||||||
ChromeImporter::ChromeImporter(QObject* parent)
|
ChromeImporter::ChromeImporter(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -57,7 +57,7 @@ QList<BookmarksModel::Bookmark> ChromeImporter::exportBookmarks()
|
||||||
m_file.close();
|
m_file.close();
|
||||||
|
|
||||||
QStringList parsedBookmarks;
|
QStringList parsedBookmarks;
|
||||||
QRegExp rx("\\{(\\s*)\"date_added(.*)\"(\\s*)\\}", Qt::CaseSensitive);
|
QzRegExp rx("\\{(\\s*)\"date_added(.*)\"(\\s*)\\}", Qt::CaseSensitive);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#include "htmlimporter.h"
|
#include "htmlimporter.h"
|
||||||
#include "bookmarksimportdialog.h"
|
#include "bookmarksimportdialog.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
|
|
||||||
HtmlImporter::HtmlImporter(QObject* parent)
|
HtmlImporter::HtmlImporter(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -100,7 +100,7 @@ QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||||
|
|
||||||
if (nearest == posOfFolder) {
|
if (nearest == posOfFolder) {
|
||||||
// Next is folder
|
// Next is folder
|
||||||
QRegExp rx("<dt><h3(.*)>(.*)</h3>");
|
QzRegExp rx("<dt><h3(.*)>(.*)</h3>");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(string);
|
rx.indexIn(string);
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Next is link
|
// Next is link
|
||||||
QRegExp rx("<dt><a(.*)>(.*)</a>");
|
QzRegExp rx("<dt><a(.*)>(.*)</a>");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(string);
|
rx.indexIn(string);
|
||||||
|
|
||||||
QString arguments = rx.cap(1);
|
QString arguments = rx.cap(1);
|
||||||
QString linkName = rx.cap(2).trimmed();
|
QString linkName = rx.cap(2).trimmed();
|
||||||
|
|
||||||
QRegExp rx2("href=\"(.*)\"");
|
QzRegExp rx2("href=\"(.*)\"");
|
||||||
rx2.setMinimal(true);
|
rx2.setMinimal(true);
|
||||||
rx2.indexIn(arguments);
|
rx2.indexIn(arguments);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "operaimporter.h"
|
#include "operaimporter.h"
|
||||||
#include "bookmarksimportdialog.h"
|
#include "bookmarksimportdialog.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
OperaImporter::OperaImporter(QObject* parent)
|
OperaImporter::OperaImporter(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -50,7 +51,7 @@ QList<BookmarksModel::Bookmark> OperaImporter::exportBookmarks()
|
||||||
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
||||||
m_file.close();
|
m_file.close();
|
||||||
|
|
||||||
QRegExp rx("#URL(.*)CREATED", Qt::CaseSensitive);
|
QzRegExp rx("#URL(.*)CREATED", Qt::CaseSensitive);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -58,7 +59,7 @@ QList<BookmarksModel::Bookmark> OperaImporter::exportBookmarks()
|
||||||
QString string = rx.cap(1);
|
QString string = rx.cap(1);
|
||||||
pos += rx.matchedLength();
|
pos += rx.matchedLength();
|
||||||
|
|
||||||
QRegExp rx2("NAME=(.*)\\n");
|
QzRegExp rx2("NAME=(.*)\\n");
|
||||||
rx2.setMinimal(true);
|
rx2.setMinimal(true);
|
||||||
rx2.indexIn(string);
|
rx2.indexIn(string);
|
||||||
QString name = rx2.cap(1).trimmed();
|
QString name = rx2.cap(1).trimmed();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "downloadmanager.h"
|
#include "downloadmanager.h"
|
||||||
#include "qztools.h"
|
#include "qztools.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
@ -129,13 +130,13 @@ QString DownloadFileHelper::parseContentDisposition(const QByteArray &header)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We try to use UTF-8 encoded filename first if present
|
// We try to use UTF-8 encoded filename first if present
|
||||||
if (value.contains(QRegExp("[ ;]{1,}filename*\\*\\s*=\\s*UTF-8''", Qt::CaseInsensitive))) {
|
if (value.contains(QzRegExp("[ ;]{1,}filename*\\*\\s*=\\s*UTF-8''", Qt::CaseInsensitive))) {
|
||||||
QRegExp reg("filename\\s*\\*\\s*=\\s*UTF-8''([^;]*)", Qt::CaseInsensitive);
|
QzRegExp reg("filename\\s*\\*\\s*=\\s*UTF-8''([^;]*)", Qt::CaseInsensitive);
|
||||||
reg.indexIn(value);
|
reg.indexIn(value);
|
||||||
path = QUrl::fromPercentEncoding(reg.cap(1).toUtf8()).trimmed();
|
path = QUrl::fromPercentEncoding(reg.cap(1).toUtf8()).trimmed();
|
||||||
}
|
}
|
||||||
else if (value.contains(QRegExp("[ ;]{1,}filename\\s*=", Qt::CaseInsensitive))) {
|
else if (value.contains(QzRegExp("[ ;]{1,}filename\\s*=", Qt::CaseInsensitive))) {
|
||||||
QRegExp reg("[ ;]{1,}filename\\s*=(.*)", Qt::CaseInsensitive);
|
QzRegExp reg("[ ;]{1,}filename\\s*=(.*)", Qt::CaseInsensitive);
|
||||||
reg.indexIn(value);
|
reg.indexIn(value);
|
||||||
path = reg.cap(1).trimmed();
|
path = reg.cap(1).trimmed();
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ QString DownloadFileHelper::parseContentDisposition(const QByteArray &header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QRegExp reg("([^;]*)", Qt::CaseInsensitive);
|
QzRegExp reg("([^;]*)", Qt::CaseInsensitive);
|
||||||
reg.indexIn(path);
|
reg.indexIn(path);
|
||||||
path = reg.cap(1).trimmed();
|
path = reg.cap(1).trimmed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,6 @@ include(../defines.pri)
|
||||||
include(../../translations/translations.pri)
|
include(../../translations/translations.pri)
|
||||||
#include(../../tests/modeltest/modeltest.pri)
|
#include(../../tests/modeltest/modeltest.pri)
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 5) {
|
|
||||||
include(3rdparty/qftp.pri)
|
|
||||||
}
|
|
||||||
|
|
||||||
contains(DEFINES, USE_QTWEBKIT_2_2) {
|
contains(DEFINES, USE_QTWEBKIT_2_2) {
|
||||||
include(plugins/qtwebkit/qtwebkit-plugins.pri)
|
include(plugins/qtwebkit/qtwebkit-plugins.pri)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +211,7 @@ SOURCES += \
|
||||||
tools/menubar.cpp \
|
tools/menubar.cpp \
|
||||||
navigation/navigationcontainer.cpp \
|
navigation/navigationcontainer.cpp \
|
||||||
tools/horizontallistwidget.cpp \
|
tools/horizontallistwidget.cpp \
|
||||||
tools/mactoolbutton.cpp
|
tools/mactoolbutton.cpp \
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
webview/tabpreview.h \
|
webview/tabpreview.h \
|
||||||
|
@ -385,7 +381,8 @@ HEADERS += \
|
||||||
tools/menubar.h \
|
tools/menubar.h \
|
||||||
navigation/navigationcontainer.h \
|
navigation/navigationcontainer.h \
|
||||||
tools/horizontallistwidget.h \
|
tools/horizontallistwidget.h \
|
||||||
tools/mactoolbutton.h
|
tools/mactoolbutton.h \
|
||||||
|
tools/qzregexp.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
@ -441,6 +438,12 @@ RESOURCES += \
|
||||||
data/html.qrc \
|
data/html.qrc \
|
||||||
data/data.qrc
|
data/data.qrc
|
||||||
|
|
||||||
|
isEqual(QT_MAJOR_VERSION, 5) {
|
||||||
|
include(3rdparty/qftp.pri)
|
||||||
|
|
||||||
|
SOURCES += tools/qzregexp.cpp
|
||||||
|
}
|
||||||
|
|
||||||
!mac:unix {
|
!mac:unix {
|
||||||
target.path = $$library_folder
|
target.path = $$library_folder
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
|
|
||||||
#include "opensearchengine.h"
|
#include "opensearchengine.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
#include "opensearchenginedelegate.h"
|
#include "opensearchenginedelegate.h"
|
||||||
|
|
||||||
#include <qbuffer.h>
|
#include <qbuffer.h>
|
||||||
|
@ -139,7 +139,7 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString
|
||||||
result.replace(QLatin1String("{language}"), language);
|
result.replace(QLatin1String("{language}"), language);
|
||||||
result.replace(QLatin1String("{inputEncoding}"), QLatin1String("UTF-8"));
|
result.replace(QLatin1String("{inputEncoding}"), QLatin1String("UTF-8"));
|
||||||
result.replace(QLatin1String("{outputEncoding}"), QLatin1String("UTF-8"));
|
result.replace(QLatin1String("{outputEncoding}"), QLatin1String("UTF-8"));
|
||||||
result.replace(QRegExp(QLatin1String("\\{([^\\}]*:|)source\\??\\}")), QCoreApplication::applicationName());
|
result.replace(QzRegExp(QLatin1String("\\{([^\\}]*:|)source\\??\\}")), QCoreApplication::applicationName());
|
||||||
result.replace(QLatin1String("{searchTerms}"), QLatin1String(QUrl::toPercentEncoding(searchTerm)));
|
result.replace(QLatin1String("{searchTerms}"), QLatin1String(QUrl::toPercentEncoding(searchTerm)));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -152,7 +152,7 @@ void SourceViewer::loadSource()
|
||||||
|
|
||||||
QString html = m_frame.data()->toHtml();
|
QString html = m_frame.data()->toHtml();
|
||||||
// Remove AdBlock element hiding rules
|
// Remove AdBlock element hiding rules
|
||||||
html.remove(QRegExp("<style type=\"text/css\">\n/\\* AdBlock for QupZilla \\*/\n.*\\{display: none !important;\\}\n</style>"));
|
html.remove(QzRegExp("<style type=\"text/css\">\n/\\* AdBlock for QupZilla \\*/\n.*\\{display: none !important;\\}\n</style>"));
|
||||||
m_sourceEdit->setPlainText(html);
|
m_sourceEdit->setPlainText(html);
|
||||||
|
|
||||||
// Highlight selectedHtml
|
// Highlight selectedHtml
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "licenseviewer.h"
|
#include "licenseviewer.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -119,7 +120,7 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &name)
|
||||||
|
|
||||||
QString theme_info = QzTools::readAllFileContents(path + "theme.info");
|
QString theme_info = QzTools::readAllFileContents(path + "theme.info");
|
||||||
|
|
||||||
QRegExp rx("Name:(.*)\\n");
|
QzRegExp rx("Name:(.*)\\n");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(theme_info);
|
rx.indexIn(theme_info);
|
||||||
if (rx.captureCount() == 1) {
|
if (rx.captureCount() == 1) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -67,7 +67,7 @@ HtmlHighlighter::HtmlHighlighter(QTextDocument* parent)
|
||||||
QStringList keywordPatterns;
|
QStringList keywordPatterns;
|
||||||
keywordPatterns << "</?([A-Za-z:0-9]{1,20})/?(>| )?" << ">" << "(<!DOCTYPE html>|<!DOCTYPE html PUBLIC)";
|
keywordPatterns << "</?([A-Za-z:0-9]{1,20})/?(>| )?" << ">" << "(<!DOCTYPE html>|<!DOCTYPE html PUBLIC)";
|
||||||
foreach(const QString & pattern, keywordPatterns) {
|
foreach(const QString & pattern, keywordPatterns) {
|
||||||
rule.pattern = QRegExp(pattern);
|
rule.pattern = QzRegExp(pattern);
|
||||||
rule.format = tagFormat;
|
rule.format = tagFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
}
|
}
|
||||||
|
@ -75,13 +75,13 @@ HtmlHighlighter::HtmlHighlighter(QTextDocument* parent)
|
||||||
// options: <tag option1="" option2="">
|
// options: <tag option1="" option2="">
|
||||||
tagOptionsFormat.setForeground(Qt::black);
|
tagOptionsFormat.setForeground(Qt::black);
|
||||||
tagOptionsFormat.setFontWeight(QFont::Bold);
|
tagOptionsFormat.setFontWeight(QFont::Bold);
|
||||||
rule.pattern = QRegExp("(\\S{2,20})=\"");
|
rule.pattern = QzRegExp("(\\S{2,20})=\"");
|
||||||
rule.format = tagOptionsFormat;
|
rule.format = tagOptionsFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
// " " strings
|
// " " strings
|
||||||
quotationFormat.setForeground(Qt::darkGreen);
|
quotationFormat.setForeground(Qt::darkGreen);
|
||||||
QRegExp rx("\".*\"");
|
QzRegExp rx("\".*\"");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rule.pattern = rx;
|
rule.pattern = rx;
|
||||||
rule.format = quotationFormat;
|
rule.format = quotationFormat;
|
||||||
|
@ -89,14 +89,14 @@ HtmlHighlighter::HtmlHighlighter(QTextDocument* parent)
|
||||||
|
|
||||||
// <!-- --> comments
|
// <!-- --> comments
|
||||||
multiLineCommentFormat.setForeground(Qt::gray);
|
multiLineCommentFormat.setForeground(Qt::gray);
|
||||||
commentStartExpression = QRegExp("<!--");
|
commentStartExpression = QzRegExp("<!--");
|
||||||
commentEndExpression = QRegExp("-->");
|
commentEndExpression = QzRegExp("-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlHighlighter::highlightBlock(const QString &text)
|
void HtmlHighlighter::highlightBlock(const QString &text)
|
||||||
{
|
{
|
||||||
foreach(const HighlightingRule & rule, highlightingRules) {
|
foreach(const HighlightingRule & rule, highlightingRules) {
|
||||||
QRegExp expression(rule.pattern);
|
QzRegExp expression(rule.pattern);
|
||||||
int index = expression.indexIn(text);
|
int index = expression.indexIn(text);
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
int length = expression.matchedLength();
|
int length = expression.matchedLength();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
class QTextDocument;
|
class QTextDocument;
|
||||||
|
|
||||||
|
@ -75,14 +76,14 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct HighlightingRule {
|
struct HighlightingRule {
|
||||||
QRegExp pattern;
|
QzRegExp pattern;
|
||||||
QTextCharFormat format;
|
QTextCharFormat format;
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<HighlightingRule> highlightingRules;
|
QVector<HighlightingRule> highlightingRules;
|
||||||
|
|
||||||
QRegExp commentStartExpression;
|
QzRegExp commentStartExpression;
|
||||||
QRegExp commentEndExpression;
|
QzRegExp commentEndExpression;
|
||||||
|
|
||||||
QTextCharFormat tagFormat;
|
QTextCharFormat tagFormat;
|
||||||
QTextCharFormat tagOptionsFormat;
|
QTextCharFormat tagOptionsFormat;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -15,9 +15,11 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include <QNetworkReply>
|
|
||||||
#include "iconfetcher.h"
|
#include "iconfetcher.h"
|
||||||
#include "followredirectreply.h"
|
#include "followredirectreply.h"
|
||||||
|
#include "qzregexp.h"
|
||||||
|
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
IconFetcher::IconFetcher(QObject* parent)
|
IconFetcher::IconFetcher(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -48,7 +50,7 @@ void IconFetcher::pageDownloaded()
|
||||||
QUrl replyUrl = reply->url();
|
QUrl replyUrl = reply->url();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
QRegExp rx("<link(.*)>", Qt::CaseInsensitive);
|
QzRegExp rx("<link(.*)>", Qt::CaseInsensitive);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
|
|
||||||
QString shortcutIconTag;
|
QString shortcutIconTag;
|
||||||
|
@ -72,7 +74,7 @@ void IconFetcher::pageDownloaded()
|
||||||
newReply = new FollowRedirectReply(faviconUrl, m_manager);
|
newReply = new FollowRedirectReply(faviconUrl, m_manager);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QRegExp rx("href=\"(.*)\"", Qt::CaseInsensitive);
|
QzRegExp rx("href=\"(.*)\"", Qt::CaseInsensitive);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(shortcutIconTag);
|
rx.indexIn(shortcutIconTag);
|
||||||
QUrl url = QUrl(rx.cap(1));
|
QUrl url = QUrl(rx.cap(1));
|
||||||
|
|
87
src/lib/tools/qzregexp.cpp
Normal file
87
src/lib/tools/qzregexp.cpp
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "qzregexp.h"
|
||||||
|
#include "qztools.h"
|
||||||
|
|
||||||
|
#if (QT_VERSION >= 0x050000)
|
||||||
|
QzRegExp::QzRegExp()
|
||||||
|
: QRegularExpression(QString(), QRegularExpression::DotMatchesEverythingOption)
|
||||||
|
, m_matchedLength(-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QzRegExp::QzRegExp(const QString &pattern, Qt::CaseSensitivity cs)
|
||||||
|
: QRegularExpression(pattern, QRegularExpression::DotMatchesEverythingOption)
|
||||||
|
, m_matchedLength(-1)
|
||||||
|
{
|
||||||
|
if (cs == Qt::CaseInsensitive) {
|
||||||
|
setPatternOptions(patternOptions() | QRegularExpression::CaseInsensitiveOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QzRegExp::QzRegExp(const QzRegExp &re)
|
||||||
|
: QRegularExpression(re)
|
||||||
|
, m_matchedLength(-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QzRegExp::setMinimal(bool minimal)
|
||||||
|
{
|
||||||
|
QRegularExpression::PatternOptions opt;
|
||||||
|
|
||||||
|
if (minimal) {
|
||||||
|
opt = patternOptions() | QRegularExpression::InvertedGreedinessOption;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
opt = patternOptions() & ~QRegularExpression::InvertedGreedinessOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPatternOptions(opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
int QzRegExp::indexIn(const QString &str, int offset) const
|
||||||
|
{
|
||||||
|
QzRegExp* that = const_cast<QzRegExp*>(this);
|
||||||
|
QRegularExpressionMatch m = match(str, offset);
|
||||||
|
|
||||||
|
if (!m.hasMatch()) {
|
||||||
|
that->m_matchedLength = -1;
|
||||||
|
that->m_capturedTexts.clear();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
that->m_matchedLength = m.capturedLength();
|
||||||
|
that->m_capturedTexts = m.capturedTexts();
|
||||||
|
return m.capturedStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
int QzRegExp::matchedLength() const
|
||||||
|
{
|
||||||
|
return m_matchedLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QzRegExp::cap(int nth) const
|
||||||
|
{
|
||||||
|
if (!QzTools::listContainsIndex(m_capturedTexts, nth)) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_capturedTexts.at(nth);
|
||||||
|
}
|
||||||
|
#endif // (QT_VERSION >= 0x050000)
|
||||||
|
|
52
src/lib/tools/qzregexp.h
Normal file
52
src/lib/tools/qzregexp.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef QZREGEXP_H
|
||||||
|
#define QZREGEXP_H
|
||||||
|
|
||||||
|
#include <QObject> // Needed for QT_VERSION
|
||||||
|
|
||||||
|
#if (QT_VERSION < 0x050000)
|
||||||
|
// Qt 4 - use QRegExp directly
|
||||||
|
#include <QRegExp>
|
||||||
|
#define QzRegExp QRegExp
|
||||||
|
#else // Qt 5
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "qz_namespace.h"
|
||||||
|
|
||||||
|
class QT_QUPZILLA_EXPORT QzRegExp : public QRegularExpression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QzRegExp();
|
||||||
|
QzRegExp(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||||
|
QzRegExp(const QzRegExp &re);
|
||||||
|
|
||||||
|
void setMinimal(bool minimal);
|
||||||
|
int indexIn(const QString &str, int offset = 0) const;
|
||||||
|
int matchedLength() const;
|
||||||
|
QString cap(int nth = 0) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList m_capturedTexts;
|
||||||
|
int m_matchedLength;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // Qt 5
|
||||||
|
|
||||||
|
#endif // QZREGEXP_H
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* GreaseMonkey plugin for QupZilla
|
* GreaseMonkey plugin for QupZilla
|
||||||
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2012-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
GM_Downloader::GM_Downloader(const QNetworkRequest &request, GM_Manager* manager)
|
GM_Downloader::GM_Downloader(const QNetworkRequest &request, GM_Manager* manager)
|
||||||
|
@ -72,7 +72,7 @@ void GM_Downloader::scriptDownloaded()
|
||||||
QSettings settings(m_manager->settinsPath() + "greasemonkey/requires/requires.ini", QSettings::IniFormat);
|
QSettings settings(m_manager->settinsPath() + "greasemonkey/requires/requires.ini", QSettings::IniFormat);
|
||||||
settings.beginGroup("Files");
|
settings.beginGroup("Files");
|
||||||
|
|
||||||
QRegExp rx("@require(.*)\\n");
|
QzRegExp rx("@require(.*)\\n");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(response);
|
rx.indexIn(response);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "gm_manager.h"
|
#include "gm_manager.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -176,7 +176,7 @@ void GM_Script::parseScript()
|
||||||
|
|
||||||
QString fileData = QString::fromUtf8(file.readAll());
|
QString fileData = QString::fromUtf8(file.readAll());
|
||||||
|
|
||||||
QRegExp rx("// ==UserScript==(.*)// ==/UserScript==");
|
QzRegExp rx("// ==UserScript==(.*)// ==/UserScript==");
|
||||||
rx.indexIn(fileData);
|
rx.indexIn(fileData);
|
||||||
QString metadataBlock = rx.cap(1).trimmed();
|
QString metadataBlock = rx.cap(1).trimmed();
|
||||||
|
|
||||||
|
|
|
@ -80,22 +80,22 @@ void GM_UrlMatcher::parsePattern(QString pattern)
|
||||||
pattern = pattern.mid(1);
|
pattern = pattern.mid(1);
|
||||||
pattern = pattern.left(pattern.size() - 1);
|
pattern = pattern.left(pattern.size() - 1);
|
||||||
|
|
||||||
m_regExp = QRegExp(pattern, Qt::CaseInsensitive);
|
m_regExp = QzRegExp(pattern, Qt::CaseInsensitive);
|
||||||
m_useRegExp = true;
|
m_useRegExp = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pattern.contains(QLatin1String(".tld"))) {
|
if (pattern.contains(QLatin1String(".tld"))) {
|
||||||
|
|
||||||
pattern.replace(QRegExp("(\\W)"), QLatin1String("\\\\1"))
|
pattern.replace(QzRegExp("(\\W)"), QLatin1String("\\\\1"))
|
||||||
.replace(QRegExp("\\*+"), QLatin1String("*"))
|
.replace(QzRegExp("\\*+"), QLatin1String("*"))
|
||||||
.replace(QRegExp("^\\\\\\|"), QLatin1String("^"))
|
.replace(QzRegExp("^\\\\\\|"), QLatin1String("^"))
|
||||||
.replace(QRegExp("\\\\\\|$"), QLatin1String("$"))
|
.replace(QzRegExp("\\\\\\|$"), QLatin1String("$"))
|
||||||
.replace(QRegExp("\\\\\\*"), QLatin1String(".*"))
|
.replace(QzRegExp("\\\\\\*"), QLatin1String(".*"))
|
||||||
.replace(QLatin1String("\\.tld"), QLatin1String("\\.[a-z.]{2,6}"));
|
.replace(QLatin1String("\\.tld"), QLatin1String("\\.[a-z.]{2,6}"));
|
||||||
|
|
||||||
m_useRegExp = true;
|
m_useRegExp = true;
|
||||||
m_regExp = QRegExp(pattern, Qt::CaseInsensitive);
|
m_regExp = QzRegExp(pattern, Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_matchString = pattern;
|
m_matchString = pattern;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* GreaseMonkey plugin for QupZilla
|
* GreaseMonkey plugin for QupZilla
|
||||||
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2012-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#define GM_URLMATCHER_H
|
#define GM_URLMATCHER_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegExp>
|
#include "qzregexp.h"
|
||||||
|
|
||||||
class GM_UrlMatcher
|
class GM_UrlMatcher
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ private:
|
||||||
QString m_pattern;
|
QString m_pattern;
|
||||||
|
|
||||||
QString m_matchString;
|
QString m_matchString;
|
||||||
QRegExp m_regExp;
|
QzRegExp m_regExp;
|
||||||
|
|
||||||
bool m_useRegExp;
|
bool m_useRegExp;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user