all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#36098: 26.1; Incorrect epg--decode-percent-escape
@ 2019-06-05 13:49 Christophe TROESTLER
  2019-06-05 14:49 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2019-06-05 13:49 UTC (permalink / raw)
  To: 36098

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


The code

(decode-coding-string
 (epg--decode-percent-escape "D%C3%A9partement")
 'utf-8)

should return "Département" but does not because the decoding of the percent string is done with multibyte.

The attached patch fixes this.

Best,
C.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-epg-Use-unibyte-string-to-decode-percent-escape.patch --]
[-- Type: text/x-diff; name="0001-epg-Use-unibyte-string-to-decode-percent-escape.patch", Size: 2682 bytes --]

From b9e1f7f39557e4a771caf151f3bc8dbbd408a074 Mon Sep 17 00:00:00 2001
From: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Date: Wed, 5 Jun 2019 15:37:04 +0200
Subject: [PATCH] epg: Use unibyte string to decode percent escape
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

Fixes

    (decode-coding-string
     (epg--decode-percent-escape "D%C3%A9partement")
     'utf-8)

which should return "Département".
---
 lisp/epg.el | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index 0400716845..0c11a8c7c0 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -770,9 +770,7 @@ epg--status-USERID_HINT
 	     (user-id (match-string 2 string))
 	     (entry (assoc key-id epg-user-id-alist)))
 	(condition-case nil
-	    (setq user-id (decode-coding-string
-			   (epg--decode-percent-escape user-id)
-			   'utf-8))
+	    (setq user-id (epg--decode-percent-escape user-id))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -899,9 +897,7 @@ epg--status-*SIG
 	(condition-case nil
 	    (if (eq (epg-context-protocol context) 'CMS)
 		(setq user-id (epg-dn-from-string user-id))
-	      (setq user-id (decode-coding-string
-			     (epg--decode-percent-escape user-id)
-			     'utf-8)))
+	      (setq user-id (epg--decode-percent-escape user-id)))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -1177,9 +1173,7 @@ epg--status-IMPORTED
 	     (user-id (match-string 2 string))
 	     (entry (assoc key-id epg-user-id-alist)))
 	(condition-case nil
-	    (setq user-id (decode-coding-string
-			   (epg--decode-percent-escape user-id)
-			   'utf-8))
+	    (setq user-id (epg--decode-percent-escape user-id))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -2020,6 +2014,7 @@ epg-edit-key
     (epg-reset context)))
 
 (defun epg--decode-percent-escape (string)
+  (setq string (string-to-unibyte string))
   (let ((index 0))
     (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)"
 			 string index)
@@ -2027,10 +2022,11 @@ epg--decode-percent-escape
 	  (setq string (replace-match "%" t t string)
 		index (1- (match-end 0)))
 	(setq string (replace-match
-		      (string (string-to-number (match-string 3 string) 16))
+		      (byte-to-string
+                       (string-to-number (match-string 3 string) 16))
 		      t t string)
 	      index (- (match-end 0) 2))))
-    string))
+    (decode-coding-string string 'utf-8)))
 
 (defun epg--decode-hexstring (string)
   (let ((index 0))
-- 
2.20.1


[-- Attachment #3: ATT00001.txt --]
[-- Type: text/plain, Size: 10761 bytes --]




In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.4)
 of 2019-02-03, modified by Debian built on zam904
Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
System Description:	Debian GNU/Linux 10 (buster)

Recent messages:
Git finished
Running git commit --amend
Diffing changes to be committed (C-g to abort diffing)
When done with a buffer, type C-c C-c
Type C-c C-c to finish, or C-c C-k to cancel
Mark set
Saving file /home/trch/software/emacs/.git/COMMIT_EDITMSG...
Wrote /home/trch/software/emacs/.git/COMMIT_EDITMSG
Git finished
Making completion list... [2 times]

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-26.1+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: mu4e:view

Minor modes in effect:
  visual-fill-column-mode: t
  TeX-PDF-mode: t
  global-magit-file-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  desktop-save-mode: t
  show-paren-mode: t
  global-edit-server-edit-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
~/software/OCaml/dune/editor-integration/emacs/dune-flymake hides /home/trch/.opam/4.07.1/share/emacs/site-lisp/dune-flymake
~/software/OCaml/dune/editor-integration/emacs/dune hides /home/trch/.opam/4.07.1/share/emacs/site-lisp/dune
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/deb-view hides /usr/share/emacs/site-lisp/elpa/debian-el-37/deb-view
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-bug hides /usr/share/emacs/site-lisp/elpa/debian-el-37/debian-bug
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/apt-utils hides /usr/share/emacs/site-lisp/elpa/debian-el-37/apt-utils
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/preseed hides /usr/share/emacs/site-lisp/elpa/debian-el-37/preseed
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/apt-sources hides /usr/share/emacs/site-lisp/elpa/debian-el-37/apt-sources
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-autoloads hides /usr/share/emacs/site-lisp/elpa/debian-el-37/debian-autoloads
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el hides /usr/share/emacs/site-lisp/elpa/debian-el-37/debian-el
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el-autoloads hides /usr/share/emacs/site-lisp/elpa/debian-el-37/debian-el-autoloads
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/gnus-BTS hides /usr/share/emacs/site-lisp/elpa/debian-el-37/gnus-BTS
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el-pkg hides /usr/share/emacs/site-lisp/elpa/debian-el-37/debian-el-pkg
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/deb-view hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/deb-view
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/apt-utils hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/apt-utils
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/preseed hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/preseed
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-bug hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/debian-bug
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/apt-sources hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/apt-sources
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-autoloads hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/debian-autoloads
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/debian-el
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el-autoloads hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/debian-el-autoloads
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/gnus-BTS hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/gnus-BTS
/home/trch/.emacs.d/elpa/debian-el-20181020.1513/debian-el-pkg hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37/debian-el-pkg
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/26.1/lisp/textmodes/rst

Features:
(shadow emacsbug rect debug find-dired sh-script executable
bug-reference magit-extras tabify man reftex-sel cursor-sensor
reftex-ref reftex-toc ibuf-ext ibuffer ibuffer-loaddefs markdown-mode
dabbrev cus-edit cus-start cus-load cl-print mhtml-mode css-mode eww
mm-url url-queue url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf js cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sgml-mode view
cal-china lunar solar cal-dst cal-islam holidays hol-loaddefs cal-move
network-stream nsm starttls mailalias reftex-parse timezone sort
gnus-cite smiley shr-color color url-util shr svg dom mm-archive
mail-extr qp grep eieio-opt help-fns radix-tree misearch multi-isearch
visual-fill-column face-remap texmathp latexenc org-rmail org-mhe
org-irc org-info org-gnus nnir org-docview org-bibtex org-bbdb org-w3m
merlin-ac auto-complete popup tuareg caml-help find-file flycheck json
map elec-pair vc-git reftex-auc preview prv-emacs tex-buf reftex-dcr
reftex reftex-loaddefs reftex-vars flyspell ispell latex latex-flymake
tex-ispell tex-style tex-mode font-latex tex dbus xml bibtex
dune-flymake flymake-proc flymake compile warnings dune skeleton smie
utop utop-minor-mode pcase merlin-cap merlin caml-types caml-emacs
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func imenu
magit-diff smerge-mode diff-mode magit-core magit-autorevert
magit-margin magit-transient magit-process magit-mode transient
git-commit magit-git magit-section magit-utils crm log-edit pcvs-util
add-log with-editor cl-extra async-bytecomp async shell subr-x dash
erc-goodies erc erc-backend erc-compat pp org-mu4e org-agenda
mu4e-icalendar gnus-icalendar org-capture mu4e-contrib mu4e desktop
frameset mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main
mu4e-view thingatpt browse-url gnus-art mm-uu mml2015 mm-view mml-smime
smime dig mailcap gnus-sum gnus-group gnus-undo gnus-start gnus-cloud
nnimap nnmail mail-source tls gnutls utf7 netrc nnoo parse-time
gnus-spec gnus-int gnus-range gnus-win gnus nnheader wid-edit
mu4e-headers mu4e-compose mu4e-context mu4e-draft mu4e-actions ido
rfc2368 smtpmail sendmail mu4e-mark mu4e-message flow-fill mu4e-proc
mu4e-utils doc-view jka-compr image-mode mu4e-lists mu4e-vars message
rmc puny dired dired-loaddefs rfc822 mml mml-sec gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev mail-utils gmm-utils mailheader hl-line
mu4e-meta adoc-mode tempo markup-faces org-element avl-tree generator
org org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint comint
ansi-color ring ob-core ob-eval org-compat org-macs org-loaddefs
format-spec find-func epa-file epa derived epg cl quail help-mode
mm-util mail-prsvr autorevert filenotify edmacro kmacro paren icalendar
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs edit-server
advice server finder-inf tex-site debian-el gh-common marshal
eieio-compat rx info package easymenu epg-config url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv
cl-loaddefs cl-lib time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 853414 163414)
 (symbols 48 67685 1)
 (miscs 40 5113 2638)
 (strings 32 246947 28395)
 (string-bytes 1 7409632)
 (vectors 16 89671)
 (vector-slots 8 2333701 146152)
 (floats 8 1347 843)
 (intervals 56 22127 2056)
 (buffers 992 1430))

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 13:49 bug#36098: 26.1; Incorrect epg--decode-percent-escape Christophe TROESTLER
@ 2019-06-05 14:49 ` Eli Zaretskii
  2019-06-05 15:53   ` Christophe TROESTLER
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-06-05 14:49 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: 36098

> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
> Date: Wed, 5 Jun 2019 13:49:05 +0000
> 
> The code
> 
> (decode-coding-string
>  (epg--decode-percent-escape "D%C3%A9partement")
>  'utf-8)
> 
> should return "Département" but does not because the decoding of the percent string is done with multibyte.
> 
> The attached patch fixes this.

Isn't the problem inside epg--decode-percent-escape?  I think it
should be fixed there, it shouldn't produce a multibyte string.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 14:49 ` Eli Zaretskii
@ 2019-06-05 15:53   ` Christophe TROESTLER
  2019-06-05 16:57     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2019-06-05 15:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 36098@debbugs.gnu.org


On  5 June 2019 at 16:49 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Isn't the problem inside epg--decode-percent-escape?  I think it
> should be fixed there, it shouldn't produce a multibyte string.

That's what the patch does.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 15:53   ` Christophe TROESTLER
@ 2019-06-05 16:57     ` Eli Zaretskii
  2019-06-05 17:05       ` Christophe TROESTLER
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-06-05 16:57 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: 36098

> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
> Disposition-Notification-To: Christophe TROESTLER
> 	<Christophe.TROESTLER@umons.ac.be>
> Date: Wed, 5 Jun 2019 15:53:23 +0000
> 
> > Isn't the problem inside epg--decode-percent-escape?  I think it
> > should be fixed there, it shouldn't produce a multibyte string.
> 
> That's what the patch does.

But you also moved decode-coding-string into that function; is that
correct?  Are we sure the original string was necessarily encoded in
UTF-8?

What I mean was only to let that function return a unibyte string, and
let the caller perform coding conversions.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 16:57     ` Eli Zaretskii
@ 2019-06-05 17:05       ` Christophe TROESTLER
  2019-06-05 17:29         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2019-06-05 17:05 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 36098@debbugs.gnu.org


On  5 June 2019 at 18:57 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
>> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
>> Disposition-Notification-To: Christophe TROESTLER
>> 	<Christophe.TROESTLER@umons.ac.be>
>> Date: Wed, 5 Jun 2019 15:53:23 +0000
>> 
>> > Isn't the problem inside epg--decode-percent-escape?  I think it
>> > should be fixed there, it shouldn't produce a multibyte string.
>> 
>> That's what the patch does.
>
> But you also moved decode-coding-string into that function; is that
> correct?  Are we sure the original string was necessarily encoded in
> UTF-8?

This is because this is an internal function and is always called with the same conversion.

> What I mean was only to let that function return a unibyte string, and
> let the caller perform coding conversions.

I can do that.  To avoid repetitions, what about introducing epg--decode-percent-escape-as-utf-8?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 17:05       ` Christophe TROESTLER
@ 2019-06-05 17:29         ` Eli Zaretskii
  2019-06-05 18:12           ` Christophe TROESTLER
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-06-05 17:29 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: 36098

> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
> Date: Wed, 5 Jun 2019 17:05:45 +0000
> 
> > What I mean was only to let that function return a unibyte string, and
> > let the caller perform coding conversions.
> 
> I can do that.  To avoid repetitions, what about introducing epg--decode-percent-escape-as-utf-8?

I think that would be fine, yes.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 17:29         ` Eli Zaretskii
@ 2019-06-05 18:12           ` Christophe TROESTLER
  2019-06-22  9:26             ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2019-06-05 18:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 36098@debbugs.gnu.org

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


On  5 June 2019 at 19:29 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
>> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
>> Date: Wed, 5 Jun 2019 17:05:45 +0000
>> 
>> > What I mean was only to let that function return a unibyte string, and
>> > let the caller perform coding conversions.
>> 
>> I can do that.  To avoid repetitions, what about introducing epg--decode-percent-escape-as-utf-8?
>
> I think that would be fine, yes.

Updated patch doing that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-epg-Use-unibyte-string-to-decode-percent-escape.patch --]
[-- Type: text/x-diff; name="0001-epg-Use-unibyte-string-to-decode-percent-escape.patch", Size: 2870 bytes --]

From 090ebf500ccfbc62d8e0748bcdedf770804c3f2d Mon Sep 17 00:00:00 2001
From: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Date: Wed, 5 Jun 2019 15:37:04 +0200
Subject: [PATCH] epg: Use unibyte string to decode percent escape
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

Fixes

    (decode-coding-string
     (epg--decode-percent-escape "D%C3%A9partement")
     'utf-8)

which should return "Département".
---
 lisp/epg.el | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index 0400716845..79fad1764b 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -770,9 +770,7 @@ epg--status-USERID_HINT
 	     (user-id (match-string 2 string))
 	     (entry (assoc key-id epg-user-id-alist)))
 	(condition-case nil
-	    (setq user-id (decode-coding-string
-			   (epg--decode-percent-escape user-id)
-			   'utf-8))
+	    (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -899,9 +897,7 @@ epg--status-*SIG
 	(condition-case nil
 	    (if (eq (epg-context-protocol context) 'CMS)
 		(setq user-id (epg-dn-from-string user-id))
-	      (setq user-id (decode-coding-string
-			     (epg--decode-percent-escape user-id)
-			     'utf-8)))
+	      (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -1177,9 +1173,7 @@ epg--status-IMPORTED
 	     (user-id (match-string 2 string))
 	     (entry (assoc key-id epg-user-id-alist)))
 	(condition-case nil
-	    (setq user-id (decode-coding-string
-			   (epg--decode-percent-escape user-id)
-			   'utf-8))
+	    (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))
 	  (error))
 	(if entry
 	    (setcdr entry user-id)
@@ -2020,6 +2014,7 @@ epg-edit-key
     (epg-reset context)))
 
 (defun epg--decode-percent-escape (string)
+  (setq string (string-to-unibyte string))
   (let ((index 0))
     (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)"
 			 string index)
@@ -2027,11 +2022,15 @@ epg--decode-percent-escape
 	  (setq string (replace-match "%" t t string)
 		index (1- (match-end 0)))
 	(setq string (replace-match
-		      (string (string-to-number (match-string 3 string) 16))
+		      (byte-to-string
+                       (string-to-number (match-string 3 string) 16))
 		      t t string)
 	      index (- (match-end 0) 2))))
     string))
 
+(defun epg--decode-percent-escape-as-utf-8 (string)
+  (decode-coding-string (epg--decode-percent-escape string) 'utf-8))
+
 (defun epg--decode-hexstring (string)
   (let ((index 0))
     (while (eq index (string-match "[0-9A-Fa-f][0-9A-Fa-f]" string index))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#36098: 26.1; Incorrect epg--decode-percent-escape
  2019-06-05 18:12           ` Christophe TROESTLER
@ 2019-06-22  9:26             ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2019-06-22  9:26 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: 36098-done

> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
> Date: Wed, 5 Jun 2019 18:12:06 +0000
> 
> On  5 June 2019 at 19:29 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> >> From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
> >> CC: "36098@debbugs.gnu.org" <36098@debbugs.gnu.org>
> >> Date: Wed, 5 Jun 2019 17:05:45 +0000
> >> 
> >> > What I mean was only to let that function return a unibyte string, and
> >> > let the caller perform coding conversions.
> >> 
> >> I can do that.  To avoid repetitions, what about introducing epg--decode-percent-escape-as-utf-8?
> >
> > I think that would be fine, yes.
> 
> Updated patch doing that.

Thanks, pushed.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-22  9:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-05 13:49 bug#36098: 26.1; Incorrect epg--decode-percent-escape Christophe TROESTLER
2019-06-05 14:49 ` Eli Zaretskii
2019-06-05 15:53   ` Christophe TROESTLER
2019-06-05 16:57     ` Eli Zaretskii
2019-06-05 17:05       ` Christophe TROESTLER
2019-06-05 17:29         ` Eli Zaretskii
2019-06-05 18:12           ` Christophe TROESTLER
2019-06-22  9:26             ` Eli Zaretskii

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.