diff --git a/src/filewidgets/knewfilemenu.cpp b/src/filewidgets/knewfilemenu.cpp --- a/src/filewidgets/knewfilemenu.cpp +++ b/src/filewidgets/knewfilemenu.cpp @@ -856,6 +856,34 @@ if (QDir::isAbsolutePath(name)) { url = QUrl::fromLocalFile(name); } else { + // Test to see if the user has given "." or ".." as a name + if (name == "." || name == "..") { + KGuiItem cancelGuiItem(KStandardGuiItem::cancel()); + cancelGuiItem.setText(i18nc("@action:button", "Enter a different name")); + + QDialog *confirmDialog = new QDialog(m_parentWidget); + confirmDialog->setWindowTitle(i18n("Invalid Directory Name")); + confirmDialog->setModal(m_modal); + confirmDialog->setAttribute(Qt::WA_DeleteOnClose); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(confirmDialog); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel); + KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), cancelGuiItem); + + KMessageBox::createKMessageBox(confirmDialog, buttonBox, QMessageBox::Warning, + i18n("\"%1\" has a special meaning to the operating system\nand cannot be used as the name of a folder.", name), + QStringList(), + "", + nullptr, + KMessageBox::NoExec, + QString()); + + QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(createDirectory())); + m_fileDialog = confirmDialog; + confirmDialog->show(); + m_text = ""; + return; + } if (!m_viewShowsHiddenFiles && name.startsWith('.')) { if (!writeHiddenDir) { confirmCreatingHiddenDir(name);