From 0f2ab468eb1cda3a8a1e4097775e49378e3232aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 10 Sep 2017 19:15:47 +0100 Subject: [PATCH] Disable some characters in FAT label input. --- src/fs/fat16.cpp | 8 ++++++++ src/fs/fat16.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index 7348c4b..4d0e445 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -101,6 +102,13 @@ qint64 fat16::maxLabelLength() const return 11; } +QValidator* fat16::labelValidator(QObject *parent) const +{ + QRegularExpressionValidator *m_LabelValidator = new QRegularExpressionValidator(parent); + m_LabelValidator->setRegularExpression(QRegularExpression(QStringLiteral(R"(^[^*?.,;:\/\\|+=<>\[\]"]*$)"))); + return m_LabelValidator; +} + qint64 fat16::readUsedCapacity(const QString& deviceNode) const { ExternalCommand cmd(QStringLiteral("fsck.fat"), { QStringLiteral("-n"), QStringLiteral("-v"), deviceNode }); diff --git a/src/fs/fat16.h b/src/fs/fat16.h index a992db0..31610f5 100644 --- a/src/fs/fat16.h +++ b/src/fs/fat16.h @@ -88,6 +88,7 @@ public: qint64 minCapacity() const override; qint64 maxCapacity() const override; qint64 maxLabelLength() const override; + QValidator* labelValidator(QObject *parent) const override; SupportTool supportToolName() const override; bool supportToolFound() const override;