all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
To: Eli Zaretskii <eliz@gnu.org>
Cc: billy.hotwind@gmail.com, 71500@debbugs.gnu.org
Subject: bug#71500: 28.2; Can't create/open .gpg file name contains non-ascii encoding in windows
Date: Sat, 29 Jun 2024 21:39:38 +0900	[thread overview]
Message-ID: <85sewvylbp.wl--xmue@d1.dion.ne.jp> (raw)
In-Reply-To: <868qyoj8id.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2069 bytes --]

> > As Tatsuya wrote, epg--start function calls gpg2 program with setting
> > :coding property to raw-text, thus each argument should be encoded in
> > proper coding system by a caller.  The problem would occur on any OS
> > whose file name coding system was not utf-8.
> > 
> > For example, in case of epg-decrypt-file, following change is required
> > if we need to set :coding property to raw-text for ENCODING.
> > 
> > diff --git a/lisp/epg.el b/lisp/epg.el
> > index 7bec91f616d..59870761565 100644
> > --- a/lisp/epg.el
> > +++ b/lisp/epg.el
> > @@ -1468,7 +1468,10 @@ epg-decrypt-file
> >        (progn
> >  	(setf (epg-context-output-file context)
> >                (or plain (make-temp-file "epg-output")))
> > -	(epg-start-decrypt context (epg-make-data-from-file cipher))
> > +	(epg-start-decrypt context
> > +                           (epg-make-data-from-file
> > +                            (encode-coding-string
> > +                             cipher file-name-coding-system)))
> >  	(epg-wait-for-completion context)
> >  	(epg--check-error-for-decrypt context)
> >  	(unless plain
> 
> Thanks, but this doesn't look right to me.  The problem is likely in
> the fact that epg--start sets the encoding/decoding for the epg
> process to raw-text in a way that is too broad: it affects not only
> how we encode and decode text sent to and received from GnuPG, but
> also how its command-line arguments are encoded.  And that's not what
> we want.
> 
> So I think the right fix is in epg--start: instead of setting :coding
> as part of the make-process call, it should call
> set-process-coding-system _after_ the make-process call, so that
> raw-text will affect only the text we send and receive from gpg.
> 
> Can you try such a change and see if it fixes the problem?

I tested attached patch and confirmed the issue was resolved.  I'm not
sure that :coding setting for decoding in make-process can be removed.
I mean, I don't know whether Emacs can receive output from process
between make-process and set-process-coding-system.

-- 
Kazuhiro Ito

[-- Attachment #2: 0001-Fix-non-ASCII-filename-operatiion-on-EasyPG-bug-7150.patch --]
[-- Type: message/rfc822, Size: 882 bytes --]

From: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Subject: [PATCH] Fix non-ASCII filename operatiion on EasyPG (bug#71500)
Date: Sat, 29 Jun 2024 20:56:02 +0900

* lisp/epg.el (epg--start): Don't suppress to encode arguments for
gpg2 program.
---
 lisp/epg.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index 7bec91f616d..cf59f03c724 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -676,10 +676,11 @@ epg--start
 				    :command (cons (epg-context-program context)
 						   args)
 				    :connection-type 'pipe
-				    :coding 'raw-text
+				    :coding '(raw-text . nil)
 				    :filter #'epg--process-filter
 				    :stderr error-process
 				    :noquery t))))
+    (set-process-coding-system process 'raw-text 'raw-text)
     (setf (epg-context-process context) process)))
 
 (defun epg--process-filter (process input)
-- 
2.45.1


  reply	other threads:[~2024-06-29 12:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 13:35 bug#71500: 28.2; Can't create/open .gpg file name contains non-ascii encoding in windows Tatsuya Kumazawa
2024-06-12  7:52 ` Eli Zaretskii
2024-06-27  7:30   ` Eli Zaretskii
2024-06-28 11:30     ` Kazuhiro Ito
2024-06-29 11:25       ` Eli Zaretskii
2024-06-29 12:39         ` Kazuhiro Ito [this message]
2024-06-29 12:55           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85sewvylbp.wl--xmue@d1.dion.ne.jp \
    --to=kzhr@d1.dion.ne.jp \
    --cc=71500@debbugs.gnu.org \
    --cc=billy.hotwind@gmail.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.