diff options
| author | Po Lu <luangruo@yahoo.com> | 2023-10-20 15:03:56 +0800 |
|---|---|---|
| committer | Po Lu <luangruo@yahoo.com> | 2023-10-20 15:03:56 +0800 |
| commit | 90bfb1075d1615da7f80432d6c3465210bb96f0d (patch) | |
| tree | 8feab13ae93e38576f9266116d4726078330332b /java/org/gnu/emacs/EmacsOpenActivity.java | |
| parent | e170869712295a97815044a89fa4157450f1674d (diff) | |
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.
Diffstat (limited to 'java/org/gnu/emacs/EmacsOpenActivity.java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsOpenActivity.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java index 0c0da6acd1f..f0f1068d3e2 100644 --- a/java/org/gnu/emacs/EmacsOpenActivity.java +++ b/java/org/gnu/emacs/EmacsOpenActivity.java @@ -462,10 +462,30 @@ public final class EmacsOpenActivity extends Activity /* 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 |
