From 4ee0d8a960a7c00b6147d566176cb54e4530ffa9 Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Thu, 8 Feb 2024 09:23:20 -0600 Subject: [PATCH] dockerfile: fix `escape` parser directive Signed-off-by: Hank Donnay --- rhel/dockerfile/dockerfile.go | 4 ++-- rhel/dockerfile/testdata/Escape.txtar | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 rhel/dockerfile/testdata/Escape.txtar diff --git a/rhel/dockerfile/dockerfile.go b/rhel/dockerfile/dockerfile.go index e49a3688a..3e24df4e0 100644 --- a/rhel/dockerfile/dockerfile.go +++ b/rhel/dockerfile/dockerfile.go @@ -100,9 +100,9 @@ func (p *labelParser) Run() error { if strings.Contains(v, `escape=`) { eq := strings.IndexByte(v, '=') if eq == -1 { - return fmt.Errorf("botched parser directive: %#q", i.val) + panic("string changed while parsing?") } - esc, _ := utf8.DecodeRuneInString(v[:eq+1]) + esc, _ := utf8.DecodeRuneInString(v[eq+1:]) p.lex.Escape(esc) p.unquote.Escape(esc) p.vars.Escape(esc) diff --git a/rhel/dockerfile/testdata/Escape.txtar b/rhel/dockerfile/testdata/Escape.txtar new file mode 100644 index 000000000..3e9bb865b --- /dev/null +++ b/rhel/dockerfile/testdata/Escape.txtar @@ -0,0 +1,8 @@ +-- Dockerfile -- +# escape=ꙮ +LABEL a ꙮ +ꙮ$b +-- Want -- +{ + "a": "$b" +}