From 8a944484f0d28bc372ead0842780fe697f997f5e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 6 Dec 2021 20:03:11 +0300 Subject: fix(ops/besadii): Unquote Gerrit's extra-quotes around emails Gerrit wraps RFC5322 emails in another layer of quotes when passing them as flags, and this needs to be unquoted. Otherwise hook invocations fail with cryptic errors. Change-Id: Ieeb74c662873d99a4154f8cbc92da77b039cb88e --- ops/besadii/main.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ops/besadii/main.go') diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 7c1626c745..b31d3e426a 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -297,6 +297,12 @@ func ignoreFlags(ignore []string) { // Extract the username & email from Gerrit's uploader flag and set it // on the trigger struct, for display in Buildkite. func extractChangeUploader(uploader string, trigger *buildTrigger) error { + // Gerrit passes the uploader in another extra layer of quotes. + uploader, err := strconv.Unquote(uploader) + if err != nil { + return fmt.Errorf("failed to unquote email - forgot quotes on manual invocation?: %w", err) + } + // Extract the uploader username & email from the input passed by // Gerrit (in RFC 5322 format). addr, err := mail.ParseAddress(uploader) -- cgit 1.4.1