;; Author: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, hypermedia
;; Package: debbugs
-;; Version: 0.8
+;; Version: 0.9.1
;; Package-Requires: ((async "1.6"))
;; This file is not part of GNU Emacs.
"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.
(when (stringp (cdr y))
(setcdr y (mapcar
'string-to-number (split-string (cdr y) " " t)))))
+ ;; "subject", "originator", "owner" and "summary" may be an
+ ;; xsd:base64Binary value containing a UTF-8-encoded string.
+ (dolist (attribute '(subject originator owner summary))
+ (setq y (assoc attribute (cdr (assoc 'value x))))
+ (when (stringp (cdr y))
+ (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.