[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkdelibs/KDE/4=2E6=5D_kio/kio=3A_Disallows_names_of_?=
From: Matthias Fuchs <mat69 () gmx ! net>
Date: 2011-05-31 22:01:17
Message-ID: 20110531220117.17CECA60A4 () git ! kde ! org
[Download RAW message or body]
Git commit 465ec0c76958657cdb75616f87d4e160f8615bcb by Matthias Fuchs.
Committed on 28/05/2011 at 01:17.
Pushed by mfuchs into branch 'KDE/4.6'.
Disallows names of files containing '/' or being equal to "." or "..".
CCBUG:211751
REVIEW:101456
(cherry picked from commit def6e86db16246e12660d6ba66f607a9ea6d9a58)
M +2 -2 kio/kio/kdirmodel.cpp
M +4 -2 kio/kio/kfileitemdelegate.cpp
http://commits.kde.org/kdelibs/465ec0c76958657cdb75616f87d4e160f8615bcb
diff --git a/kio/kio/kdirmodel.cpp b/kio/kio/kdirmodel.cpp
index 2243e27..96126ad 100644
--- a/kio/kio/kdirmodel.cpp
+++ b/kio/kio/kdirmodel.cpp
@@ -781,10 +781,10 @@ bool KDirModel::setData( const QModelIndex & index, const \
QVariant & value, int
KDirModelNode* node = \
static_cast<KDirModelNode*>(index.internalPointer()); const KFileItem& item = \
node->item(); const QString newName = value.toString();
- if (newName.isEmpty() || newName == item.text())
+ if (newName.isEmpty() || newName == item.text() || (newName == \
QLatin1String(".")) || (newName == QLatin1String(".."))) return true;
KUrl newurl(item.url());
- newurl.setPath(newurl.directory(KUrl::AppendTrailingSlash) + newName);
+ newurl.setPath(newurl.directory(KUrl::AppendTrailingSlash) + \
KIO::encodeFileName(newName));
KIO::Job * job = KIO::moveAs(item.url(), newurl, newurl.isLocalFile() ? \
KIO::HideProgressInfo : KIO::DefaultFlags); \
job->ui()->setAutoErrorHandlingEnabled(true); // undo handling
diff --git a/kio/kio/kfileitemdelegate.cpp b/kio/kio/kfileitemdelegate.cpp
index cb3939d..27c8fd3 100644
--- a/kio/kio/kfileitemdelegate.cpp
+++ b/kio/kio/kfileitemdelegate.cpp
@@ -1647,13 +1647,15 @@ bool KFileItemDelegate::eventFilter(QObject *object, QEvent \
*event) return true;
case Qt::Key_Enter:
- case Qt::Key_Return:
- if (editor->toPlainText().isEmpty())
+ case Qt::Key_Return: {
+ const QString text = editor->toPlainText();
+ if (text.isEmpty() || (text == QLatin1String(".")) || (text == \
QLatin1String(".."))) return true; // So a newline doesn't get inserted
emit commitData(editor);
emit closeEditor(editor, SubmitModelCache);
return true;
+ }
case Qt::Key_Escape:
emit closeEditor(editor, RevertModelCache);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic