From 6ecec8828628276b537915ca12c08ba7cf7029aa Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 9 Oct 2018 15:45:09 +0200 Subject: 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. --- debbugs/soap.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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") -- cgit v1.2.3