aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJuhani Krekelä2021-07-03 00:03:03 +0300
committerWolfgang Müller2021-07-02 23:12:03 +0200
commitf27b50ae42bce241495e41f31670ba492382a52a (patch)
tree7618005d38077c23909775ef6c8d5d1a66575d76
parentdf43ece1d063e896da43916b9a836da5226c36b9 (diff)
downloadweltschmerz-f27b50ae42bce241495e41f31670ba492382a52a.tar.gz
Only allow opening local directories
The proposed OSC 7 specification mandates [1] that the file:// URI includes the hostname, so that the terminal emulator can ignore remotely used programs' attempts to set the current working directory. However, VTE does not check the hostname component, and neither does launch_default_for_uri. Thus currently if one tries to open directory after running a remote program that used OSC 7, weltschmerz tries to open a file manager pointing at corresponding path on the local computer. weltschmerz already contains a function that checks the URI kept by VTE and returns the path only if it is on the local computer. This commit changes open_directory() to first use that, and then create a new local file:// URI based on it, unifying the behaviour of 'Open directory' and 'Open terminal'. [1] https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/20#note_294252
-rw-r--r--terminal.vala13
1 files changed, 11 insertions, 2 deletions
diff --git a/terminal.vala b/terminal.vala
index fcd5ee0..86f086f 100644
--- a/terminal.vala
+++ b/terminal.vala
@@ -374,7 +374,16 @@ class Terminal : Gtk.Overlay {
[GtkCallback]
void open_directory() {
- uri_open(vte.get_current_directory_uri());
+ var cwd = get_local_directory_path();
+ if (cwd == null)
+ return;
+
+ try {
+ uri_open(Filename.to_uri(cwd));
+ } catch (Error e) {
+ warning(e.message);
+ infobar_show(e.message, Gtk.MessageType.ERROR);
+ }
}
void vte_copy(bool html = false) {
@@ -402,7 +411,7 @@ class Terminal : Gtk.Overlay {
copy_item_text.set_sensitive(vte.get_has_selection());
copy_item_html.set_sensitive(vte.get_has_selection());
open_terminal_item.set_sensitive(get_local_directory_path() != null);
- open_directory_item.set_sensitive(vte.get_current_directory_uri() != null);
+ open_directory_item.set_sensitive(get_local_directory_path() != null);
standard_context_menu.popup_at_pointer(event);
}
return true;