diff --git a/src/vattachmentlist.cpp b/src/vattachmentlist.cpp index 4fa2a563..ab03830a 100644 --- a/src/vattachmentlist.cpp +++ b/src/vattachmentlist.cpp @@ -378,6 +378,22 @@ void VAttachmentList::handleListItemCommitData(QWidget *p_itemEdit) return; } + bool legalName = true; + if (text.isEmpty()) { + legalName = false; + } else { + QRegExp reg(VUtils::c_fileNameRegExp); + if (!reg.exactMatch(text)) { + legalName = false; + } + } + + if (!legalName) { + // Recover to old name. + item->setText(oldText); + return; + } + if (!(oldText.toLower() == text.toLower()) && m_file->findAttachment(text, false) > -1) { // Name conflict.