diff --git a/src/embed/internal/embedtest/embed_test.go b/src/embed/internal/embedtest/embed_test.go index bfd94af69d2..1337e421bda 100644 --- a/src/embed/internal/embedtest/embed_test.go +++ b/src/embed/internal/embedtest/embed_test.go @@ -60,6 +60,11 @@ func testDir(t *testing.T, f embed.FS, name string, expect ...string) { } } +// Tests for issue 49514. +var _ = '"' +var _ = '\'' +var _ = '🦆' + func TestGlobal(t *testing.T) { testFiles(t, global, "concurrency.txt", "Concurrency is not parallelism.\n") testFiles(t, global, "testdata/hello.txt", "hello, world\n") diff --git a/src/go/build/read.go b/src/go/build/read.go index 6115ef810c7..de5c33a4f84 100644 --- a/src/go/build/read.go +++ b/src/go/build/read.go @@ -240,6 +240,27 @@ func (r *importReader) findEmbed(first bool) bool { } } + case '\'': + startLine = false + for r.err == nil { + if r.eof { + r.syntaxError() + } + c = r.readByteNoBuf() + if c == '\\' { + r.readByteNoBuf() + if r.err != nil { + r.syntaxError() + return false + } + continue + } + if c == '\'' { + c = r.readByteNoBuf() + goto Reswitch + } + } + case '/': c = r.readByteNoBuf() switch c {