diff --git a/src/go/GoModuleText.ts b/src/go/GoModuleText.ts index 0a3e950216..6a62f75227 100644 --- a/src/go/GoModuleText.ts +++ b/src/go/GoModuleText.ts @@ -38,10 +38,16 @@ const quoted = (input: string): { value: string; end: number } | null => { } if (character === "\n") return null; if (character !== "\\") { - const point = input.codePointAt(index); - if (point === undefined) return null; - length += output.write(String.fromCodePoint(point), length, "utf8"); - index += point > 0xffff ? 2 : 1; + const start = index; + do { + index += 1; + } while ( + index < input.length && + input[index] !== '"' && + input[index] !== "\n" && + input[index] !== "\\" + ); + length += output.write(input.slice(start, index), length, "utf8"); continue; } const escaped = input[index + 1]; diff --git a/tests/boundary/go/goModuleText.test.ts b/tests/boundary/go/goModuleText.test.ts index 8d4e076574..e79fa5c09e 100644 --- a/tests/boundary/go/goModuleText.test.ts +++ b/tests/boundary/go/goModuleText.test.ts @@ -32,7 +32,7 @@ describe("Go producer module text", () => { it("decodes Go quoting including byte, octal and Unicode escapes without JSON substitution", () => { const text = - String.raw`build\t"key=quoted"="\a\v\xC3\xA9\303\251\u263a\U0001F680"`.replace( + String.raw`build\t"key=quoted"="literal路𐐷\a\v\xC3\xA9\303\251\u263a\U0001F680 end"`.replace( "\\t", "\t", ) + @@ -40,7 +40,7 @@ describe("Go producer module text", () => { "build\traw=`a\rb`\n"; expect(parseGoModuleBytes(Buffer.from(text))).toMatchObject({ settings: [ - { key: "key=quoted", value: "\x07\x0béé☺🚀" }, + { key: "key=quoted", value: "literal路𐐷\x07\x0béé☺🚀 end" }, { key: "raw", value: "ab" }, ], complete: true,