Treat empty mailto URIs properly under Android

* java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): If an
empty mailto: URI is supplied, ascertain if EXTRA_EMAIL is set,
then derive a mailto URI from that if so.
This commit is contained in:
Po Lu 2023-10-20 15:03:56 +08:00
parent e170869712
commit 90bfb1075d

View file

@ -462,10 +462,30 @@ private class EmacsClientThread extends Thread
/* Escape the special characters $ and " before enclosing
the string within the `message-mailto' wrapper. */
fileName = uri.toString ();
/* If fileName is merely mailto: (absent either an email
address or content), then the program launching Emacs
conceivably provided such an URI to exclude non-email
programs from being enumerated within the Share dialog;
whereupon Emacs should replace it with any address
provided as EXTRA_EMAIL. */
if (fileName.equals ("mailto:"))
{
tem = intent.getCharSequenceExtra (Intent.EXTRA_EMAIL);
if (tem != null)
fileName = "mailto:" + tem;
}
/* Subsequently, escape fileName such that it is rendered
safe to append to the command line. */
fileName = (fileName
.replace ("\\", "\\\\")
.replace ("\"", "\\\"")
.replace ("$", "\\$"));
fileName = "(message-mailto \"" + fileName + "\" ";
/* Parse the intent itself to ascertain if any