From 8734a853bcdf694a9e9444515d45dbca26b3c374 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 21 Jun 2024 14:52:16 +0200 Subject: [PATCH] plugin: fix Plugin.Confirm again --- plugin/plugin.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin/plugin.go b/plugin/plugin.go index 5a83c09..dafd4c7 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -451,6 +451,9 @@ func (p *Plugin) DisplayMessage(message string) error { if s.Type == "fail" { return fmt.Errorf("client failed to display message") } + if err := expectStanzaWithNoBody(s, 0); err != nil { + return p.fatalInteractf("%v", err) + } return nil } @@ -474,6 +477,9 @@ func (p *Plugin) RequestValue(prompt string, secret bool) (string, error) { if s.Type == "fail" { return "", fmt.Errorf("client failed to request value") } + if err := expectStanzaWithBody(s, 0); err != nil { + return "", p.fatalInteractf("%v", err) + } return string(s.Body), nil } @@ -571,9 +577,6 @@ func readOkOrFail(sr *format.StanzaReader) (*format.Stanza, error) { } return s, nil case "ok": - if s.Body != nil { - return nil, fmt.Errorf("ok stanza has %d bytes of body, want 0", len(s.Body)) - } return s, nil default: return nil, fmt.Errorf("expected ok or fail stanza, got %q", s.Type)