From 7a09181ad2e808ab769301ef8583e94c90f6e115 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 30 Nov 2014 17:27:39 +0100 Subject: [PATCH] Make sure that user doesn't enter any orphaned "-" or "--" prefixes. --- src/version.h | 2 +- src/win_addJob.cpp | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/version.h b/src/version.h index 51ea36c..c9226f6 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 4 #define VER_X264_PATCH 4 -#define VER_X264_BUILD 895 +#define VER_X264_BUILD 896 #define VER_X264_PORTABLE_EDITION (0) diff --git a/src/win_addJob.cpp b/src/win_addJob.cpp index 2cbc965..872d5fb 100644 --- a/src/win_addJob.cpp +++ b/src/win_addJob.cpp @@ -138,6 +138,25 @@ protected: return flag; } + bool checkPrefix(const QString &input) const + { + static const char *const c[3] = { "--", "-", NULL }; + for(size_t i = 0; c[i]; i++) + { + const QString prefix = QString::fromLatin1(c[i]); + if(input.startsWith(QString("%1 ").arg(prefix)) || input.contains(QString(" %1 ").arg(prefix)) || input.endsWith(prefix)) + { + qDebug("A"); + if(m_notifier) + { + m_notifier->setText(tr("Invalid parameter: %1").arg(prefix)); + } + return true; + } + } + return false; + } + const bool &setStatus(const bool &flag, const QString &toolName) const { if(flag) @@ -175,7 +194,7 @@ public: static const char* p[] = {"B", "o", "h", "p", "q", /*"fps", "frames",*/ "preset", "tune", "profile", "stdin", "crf", "bitrate", "qp", "pass", "stats", "output", "help","quiet", NULL}; - bool invalid = false; + bool invalid = checkPrefix(input); for(size_t i = 0; p[i] && (!invalid); i++) { @@ -195,7 +214,7 @@ public: { static const char* p[] = {"o", "frames", "seek", "raw", "hfyu", "slave", NULL}; - bool invalid = false; + bool invalid = checkPrefix(input); for(size_t i = 0; p[i] && (!invalid); i++) {