Skip to content

Commit c622d1d

Browse files
go/build: skip rune literals when looking for go:embed
Fixes #49514 Change-Id: Id687eead731ba49974f11d2e5b489f11eff7d07b Reviewed-on: https://go-review.googlesource.com/c/go/+/363275 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
1 parent eb68e33 commit c622d1d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/embed/internal/embedtest/embed_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func testDir(t *testing.T, f embed.FS, name string, expect ...string) {
6060
}
6161
}
6262

63+
// Tests for issue 49514.
64+
var _ = '"'
65+
var _ = '\''
66+
var _ = '🦆'
67+
6368
func TestGlobal(t *testing.T) {
6469
testFiles(t, global, "concurrency.txt", "Concurrency is not parallelism.\n")
6570
testFiles(t, global, "testdata/hello.txt", "hello, world\n")

src/go/build/read.go

+21
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,27 @@ func (r *importReader) findEmbed(first bool) bool {
240240
}
241241
}
242242

243+
case '\'':
244+
startLine = false
245+
for r.err == nil {
246+
if r.eof {
247+
r.syntaxError()
248+
}
249+
c = r.readByteNoBuf()
250+
if c == '\\' {
251+
r.readByteNoBuf()
252+
if r.err != nil {
253+
r.syntaxError()
254+
return false
255+
}
256+
continue
257+
}
258+
if c == '\'' {
259+
c = r.readByteNoBuf()
260+
goto Reswitch
261+
}
262+
}
263+
243264
case '/':
244265
c = r.readByteNoBuf()
245266
switch c {

0 commit comments

Comments
 (0)