From f105f448b33fc455498a3ce16c50003ed4c91b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 9 Oct 2017 23:56:15 +0100 Subject: [PATCH] Add a validator for LVM LV names. --- src/gui/newdialog.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index 2cc502a..ea1d6ab 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -115,6 +115,13 @@ void NewDialog::setupDialog() detailsButton->hide(); dialogWidget().comboFileSystem().removeItem(dialogWidget().comboFileSystem().findText(QStringLiteral("lvm2 pv"))); m_IsValidLVName = false; + + /* LVM logical volume name can consist of: letters numbers _ . - + + * It cannot start with underscore _ and must not be equal to . or .. or any entry in /dev/ + * QLineEdit accepts QValidator::Intermediate, so we just disable . at the beginning */ + QRegularExpression re(QStringLiteral(R"(^(?!_|\.)[\w\-.+]+)")); + QRegularExpressionValidator *validator = new QRegularExpressionValidator(re, this); + dialogWidget().lvName().setValidator(validator); } dialogWidget().editPassphrase().setMinimumPasswordLength(1);