summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinmineryt <50749166+sinmineryt@users.noreply.github.com>2021-06-13 13:38:07 +0200
committerGitHub <noreply@github.com>2021-06-13 12:38:07 +0100
commit2e1a01a499d0fd0294922c4d77b19745ed0a6960 (patch)
tree1415db37080ef3cebb73be04cb0d01c753da2385
parentd5828dbecbba71cb828dc495f35a759792b5f817 (diff)
downloadserenity-2e1a01a499d0fd0294922c4d77b19745ed0a6960.zip
TextEditor: Don't allow opening directories
Previously it was possible to open a directory in the TextEditor application. Like device files, these are now rejected with an error message.
-rw-r--r--Userland/Applications/TextEditor/MainWidget.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp
index a62d824160..83eef1b554 100644
--- a/Userland/Applications/TextEditor/MainWidget.cpp
+++ b/Userland/Applications/TextEditor/MainWidget.cpp
@@ -653,6 +653,11 @@ bool MainWidget::open_file(const String& path)
return false;
}
+ if (file->is_directory()) {
+ GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", path), "Error", GUI::MessageBox::Type::Error);
+ return false;
+ }
+
m_editor->set_text(file->read_all());
set_path(LexicalPath(path));