summaryrefslogtreecommitdiff
path: root/debbugs/soap.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-10-09 15:45:09 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-10-09 15:45:09 +0200
commit6ecec8828628276b537915ca12c08ba7cf7029aa (patch)
tree888ce2d2064c39ff5df5626cff69d40a51401f60 /debbugs/soap.scm
parent3b3945fbfc30ed1ca146d641f509c85bfe72901a (diff)
debbugs: soap->scheme: Retry decoding as Latin-1 if UTF-8 fails.
* debbugs/soap.scm (soap->scheme): Decode as ISO 8859-1 if UTF-8 decoding fails.
Diffstat (limited to 'debbugs/soap.scm')
-rw-r--r--debbugs/soap.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/debbugs/soap.scm b/debbugs/soap.scm
index 0dc8aae..eab80f0 100644
--- a/debbugs/soap.scm
+++ b/debbugs/soap.scm
@@ -169,7 +169,15 @@ name and the value."
(let* ((converter (match ((sxpath '(@ http://www.w3.org/1999/XMLSchema-instance:type *text*)) sxml)
(("xsd:string") identity)
(("xsd:base64Binary")
- (compose (cut bytevector->string <> "UTF-8") base64-decode))
+ ;; Debbugs does not tell us what encoding is
+ ;; used for the body, so we first try UTF-8 and
+ ;; fall back to ISO 8859-1 if decoding failed.
+ (compose
+ (lambda (decoded)
+ (catch 'decoding-error
+ (lambda () (bytevector->string decoded "UTF-8"))
+ (lambda _ (bytevector->string decoded "ISO 8859-1"))))
+ base64-decode))
(("xsd:int") string->number)
(("soapenc:Array") (cut soap->scheme <> #t))
(("apachens:Map")