From b3cc8c1cc3f8ba9fe2a1918602e41904f8c344ef Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 10 Sep 2020 09:50:23 +0200 Subject: [PATCH] html debug page: make spew output mangling more precise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, it also ate anything in parens in string literals, such as in “Donation (200 CHF)”! --- cmd/qrbill-api/debughtml.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/qrbill-api/debughtml.go b/cmd/qrbill-api/debughtml.go index 2955b40..a4947be 100644 --- a/cmd/qrbill-api/debughtml.go +++ b/cmd/qrbill-api/debughtml.go @@ -30,7 +30,7 @@ import ( var ( fieldNameRe = regexp.MustCompile(`
( )*([^:]+):`) stringLiteralRe = regexp.MustCompile(`"([^"]*)"`) - parenRe = regexp.MustCompile(`\(([^)]+)\) `) + typeInfoRe = regexp.MustCompile(`(
( )*([^:]+): )[^"{]+`) ) var tmpl = template.Must(template.New("").Parse(` @@ -203,7 +203,7 @@ func debugHTML(w http.ResponseWriter, r *http.Request, prefix string, qrch *qrbi sp := spew.Sdump(vars...) sp = strings.ReplaceAll(sp, "\n", "
") sp = strings.ReplaceAll(sp, " ", " ") - sp = parenRe.ReplaceAllString(sp, "") + sp = typeInfoRe.ReplaceAllString(sp, "$1") sp = stringLiteralRe.ReplaceAllStringFunc(sp, func(stringLiteral string) string { return `` + stringLiteral + "" })