emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 9fa627b 1/2: Decode xsd:base64Binary values in debbugs.el


From: Michael Albinus
Subject: [elpa] master 9fa627b 1/2: Decode xsd:base64Binary values in debbugs.el
Date: Tue, 15 Mar 2016 07:55:57 +0000

branch: master
commit 9fa627bbb3b20d842c72f1d7735deb1b839c6a2d
Author: Thomas Fitzsimmons <address@hidden>
Commit: Michael Albinus <address@hidden>

    Decode xsd:base64Binary values in debbugs.el
    
    * packages/debbugs/debbugs.el
    (debbugs-convert-soap-value-to-string): New defun.
    (debbugs-get-status): Use it to decode xsd:base64Binary values.
---
 packages/debbugs/debbugs.el |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/packages/debbugs/debbugs.el b/packages/debbugs/debbugs.el
index f145280..e4c9667 100644
--- a/packages/debbugs/debbugs.el
+++ b/packages/debbugs/debbugs.el
@@ -264,6 +264,27 @@ patch:
   "Return the list of bug numbers, according to AMOUNT (a number) latest bugs."
   (sort (car (soap-invoke debbugs-wsdl debbugs-port "newest_bugs" amount)) '<))
 
+(defun debbugs-convert-soap-value-to-string (string-value)
+  "If STRING-VALUE is unibyte, decode its contents as a UTF-8 string.
+If STRING-VALUE is a multibyte string, then `soap-client'
+received an xsd:string for this value, and will have decoded it
+already.
+
+If STRING-VALUE is a unibyte string, then `soap-client' received
+an xsd:base64Binary, and ran `base64-decode-string' on it to
+produce a unibyte string of bytes.
+
+For some reason, the Debbugs server code base64-encodes strings
+that contain UTF-8 characters, and returns them as
+xsd:base64Binary, instead of just returning them as xsd:string.
+Therefore, when STRING-VALUE is a unibyte string, we assume its
+bytes represent a UTF-8 string and decode them accordingly."
+  (if (stringp string-value)
+      (if (not (multibyte-string-p string-value))
+         (decode-coding-string string-value 'utf-8)
+       string-value)
+    (error "Invalid string value")))
+
 (defun debbugs-get-status (&rest bug-numbers)
   "Return a list of status entries for the bugs identified by BUG-NUMBERS.
 
@@ -421,6 +442,11 @@ Example:
            (when (stringp (cdr y))
              (setcdr y (mapcar
                         'string-to-number (split-string (cdr y) " " t)))))
+         ;; "originator" may be an xsd:base64Binary value containing
+         ;; a UTF-8-encoded string.
+         (dolist (attribute '(originator))
+           (setq y (assoc attribute (cdr (assoc 'value x))))
+           (setcdr y (debbugs-convert-soap-value-to-string (cdr y))))
          ;; "package" is a string, containing comma separated
          ;; package names.  "keywords" and "tags" are strings,
          ;; containing blank separated package names.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]