Browse Source

bug-fix: add attachment name check

Le Tan 8 years ago
parent
commit
37058b04df
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/vattachmentlist.cpp

+ 16 - 0
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.