]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/build: skip rune literals when looking for go:embed
authorIan Lance Taylor <iant@golang.org>
Thu, 11 Nov 2021 04:28:45 +0000 (20:28 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 11 Nov 2021 20:25:49 +0000 (20:25 +0000)
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>
src/embed/internal/embedtest/embed_test.go
src/go/build/read.go

index bfd94af69d259b4acec395b1de65c0a3ad8439b7..1337e421bda866445f5033a915a337e3dc30943e 100644 (file)
@@ -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")
index 6115ef810c786713bdc8c6696eaeccf9448c1436..de5c33a4f849ce337fabc3a62920ba36fb552563 100644 (file)
@@ -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 {