all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 70301@debbugs.gnu.org, k.ninev@cdots.bg
Subject: bug#70301: 30.0.50; secrets-create-item mangles cyrillic passwords
Date: Wed, 10 Apr 2024 17:32:43 +0200	[thread overview]
Message-ID: <87jzl5s06c.fsf@gmx.de> (raw)
In-Reply-To: <86o7aix3wq.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 09 Apr 2024 12:48:37 +0300")

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

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

> Does the patch below give good results?

Thanks for the patch. However, I believe we shouldn't fix it in
secrets.el, but in dbus.el.

> Michael, I think we have a similar problem in
> dbus-byte-array-to-string: when MULTIBYTE is non-nil, the function
> should call decode-coding-string on the unibyte string it produces
> instead of converting each byte to multibyte.  Because the bytes in
> the argument BYTE-ARRAY are not characters, they are raw bytes of the
> UTF-8 sequence, so calling 'string' on them is not TRT.

Yes. The following patch works for me. WDYT?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1437 bytes --]

diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el
index 46f85daba24..11c87e72d4e 100644
--- a/lisp/net/dbus.el
+++ b/lisp/net/dbus.el
@@ -997,17 +997,18 @@ dbus-string-to-byte-array
 STRING shall be UTF-8 coded."
   (if (zerop (length string))
       '(:array :signature "y")
-    (cons :array (mapcan (lambda (c) (list :byte c)) string))))
+    (cons :array
+          (mapcan (lambda (c) (list :byte c))
+                  (encode-coding-string string 'utf-8)))))

-(defun dbus-byte-array-to-string (byte-array &optional multibyte)
+(defun dbus-byte-array-to-string (byte-array &optional _multibyte)
   "Transform BYTE-ARRAY into UTF-8 coded string.
-BYTE-ARRAY must be a list of structure (c1 c2 ...), or a byte
-array as produced by `dbus-string-to-byte-array'.  The resulting
-string is unibyte encoded, unless MULTIBYTE is non-nil."
-  (apply
-   (if multibyte #'string #'unibyte-string)
-   (unless (equal byte-array '(:array :signature "y"))
-     (seq-filter #'characterp byte-array))))
+BYTE-ARRAY must be a unibyte list of structure (c1 c2 ...), or a byte
+array as produced by `dbus-string-to-byte-array'."
+   (if-let ((bytes (seq-filter #'characterp byte-array))
+            (string (apply #'unibyte-string bytes)))
+       (decode-coding-string string 'utf-8)
+     ""))

 (defun dbus-escape-as-identifier (string)
   "Escape an arbitrary STRING so it follows the rules for a C identifier.

  parent reply	other threads:[~2024-04-10 15:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  8:18 bug#70301: 30.0.50; secrets-create-item mangles cyrillic passwords k.ninev--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-09  9:48 ` Eli Zaretskii
2024-04-09 10:09   ` k.ninev
2024-04-09 10:23     ` Eli Zaretskii
2024-04-10 15:32   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-04-10 15:44     ` Eli Zaretskii
2024-04-10 16:10       ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-12  8:14         ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-12  8:51           ` k.ninev
2024-04-12  8:59             ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-12 11:37               ` Eli Zaretskii
2024-04-12 13:53                 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=87jzl5s06c.fsf@gmx.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=70301@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=k.ninev@cdots.bg \
    --cc=michael.albinus@gmx.de \
    /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.