mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
GM WIN: Add CR to detection (#2027)
* WIN: Add CR to detection
Saving in Notepad++ with Windows line ending prevents script injection
Post fix for #1964 and some vague references at ce67c7a455
* 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
This commit is contained in:
parent
7ac832c689
commit
9f298c352b
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user