[geary/wip/522-mailto-broken] Work around GLib inserting '///' in mailto URIs



commit e8a7d7937f8e6f2c28e549b99fdcf4184e07535b
Author: Michael Gratton <mike vee net>
Date:   Thu Sep 5 19:15:36 2019 +1000

    Work around GLib inserting '///' in mailto URIs
    
    Since GApplication::open passes GFile instances around, when `mailto`
    URIs are passed in, they are mangled by GFile to have the form
    'mailto:///...'. Check for that and work around.
    
    See GNOME/glib#1886

 src/client/application/geary-application.vala | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 11e6480b..c8f2e1b6 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -466,7 +466,16 @@ public class GearyApplication : Gtk.Application {
     public override void open(GLib.File[] targets, string hint) {
         foreach (GLib.File target in targets) {
             if (target.get_uri_scheme() == "mailto") {
-                this.new_composer.begin(target.get_uri());
+                string mailto = target.get_uri();
+                // Due to GNOME/glib#1886, the email address may be
+                // prefixed by a '///'. If so, remove it.
+                if (mailto.has_prefix("mailto:///";)) {
+                    mailto = (
+                        Geary.ComposedEmail.MAILTO_SCHEME +
+                        mailto.substring("mailto:///".length)
+                    );
+                }
+                this.new_composer.begin(mailto);
             }
         }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]