bug-fix: add attachment name check

This commit is contained in:
Le Tan 2017-09-24 14:39:19 +08:00
parent 04fa3654a4
commit 37058b04df

View File

@ -378,6 +378,22 @@ void VAttachmentList::handleListItemCommitData(QWidget *p_itemEdit)
return; 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()) if (!(oldText.toLower() == text.toLower())
&& m_file->findAttachment(text, false) > -1) { && m_file->findAttachment(text, false) > -1) {
// Name conflict. // Name conflict.