shell/source/unix/misc/senddoc.sh |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit d38e0d615c73b55d3cf2a299cfb9290f0005000b
Author:     Mike Kaganski <[email protected]>
AuthorDate: Wed Dec 18 11:18:27 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Dec 18 14:30:18 2024 +0100

    Send attachments to xdg-email also as --attach arguments
    
    Intended to handle the potential end of support of "attach" in mailto URLs,
    as discussed in https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/177.
    
    Change-Id: If1e9a7161e9805f634fcab5fb83e6f172af54d1c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178701
    Reviewed-by: Mike Kaganski <[email protected]>
    Reviewed-by: Ilmari Lauhakangas <[email protected]>
    Tested-by: Jenkins

diff --git a/shell/source/unix/misc/senddoc.sh 
b/shell/source/unix/misc/senddoc.sh
index 350e53fd0bf4..65ade8426d1f 100755
--- a/shell/source/unix/misc/senddoc.sh
+++ b/shell/source/unix/misc/senddoc.sh
@@ -68,7 +68,9 @@ case $(printf %s "$MAILER_TYPE" | sed 's/-.*$//') in
         ;;
 
     evolution | gnome | groupwise | xdg) # NB. shortened from the dash on
-        MAILER_TYPE=generic-mailto
+        if [ "$MAILER_TYPE" != "xdg-email" ]; then
+            MAILER_TYPE=generic-mailto
+        fi
         ;;
 
     dtmail)
@@ -84,6 +86,8 @@ case $(printf %s "$MAILER_TYPE" | sed 's/-.*$//') in
         ;;
 
     *)
+        MAILER_TYPE=generic-mailto
+
         # LO is configured to use something we do not recognize, or is not 
configured.
         # Try to be smart, and send the mail anyway, if we have the
         # possibility to do so.
@@ -104,7 +108,9 @@ case $(printf %s "$MAILER_TYPE" | sed 's/-.*$//') in
             exit 2
         fi
 
-        MAILER_TYPE=generic-mailto
+        if [ "$(basename "$MAILER")" = "xdg-email" ]; then
+            MAILER_TYPE=xdg-email
+        fi
         ;;
 esac
 
@@ -269,7 +275,7 @@ case $MAILER_TYPE in
         rm -f "$BODY"
         ;;
 
-    generic-mailto)
+    generic-mailto | xdg-email)
 
         while [ "$1" != "" ]; do
             case $1 in
@@ -301,6 +307,10 @@ case $MAILER_TYPE in
                     # Just add both attach and attachment "headers" - some 
apps use one, some the other
                     ATTACH_URL=$(printf file://%s "$2" | "${URI_ENCODE}")
                     
MAILTO="${MAILTO:+${MAILTO}&}attach=${ATTACH_URL}&attachment=${ATTACH_URL}"
+                    if [ "$MAILER_TYPE" = "xdg-email" ]; then
+                        # Also add the argument: see 
https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/177
+                        ATTACH="${ATTACH:+${ATTACH} }--attach \"$2\""
+                    fi
                     shift
                     ;;
                 *)
@@ -310,7 +320,7 @@ case $MAILER_TYPE in
         done
 
         MAILTO="mailto:${TO}?${MAILTO}";
-        ${MAILER} "${MAILTO}" &
+        eval "${MAILER} ${ATTACH} \"${MAILTO}\"" &
         ;;
 
     dtmail)

Reply via email to