Skip to content

Commit 0b204f9

Browse files
committed
go/build: allow ~ and ^ in #cgo directives for sr.ht import paths
Fixes #32260 Change-Id: Ib44ee33b8143d523875cf5a2bc5e36bf082801a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/199918 Run-TryBot: Elias Naur <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent a38a917 commit 0b204f9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/go/build/build.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@ func (ctxt *Context) makePathsAbsolute(args []string, srcDir string) {
15521552
// The @ is for OS X. See golang.org/issue/13720.
15531553
// The % is for Jenkins. See golang.org/issue/16959.
15541554
// The ! is because module paths may use them. See golang.org/issue/26716.
1555-
const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! "
1555+
// The ~ and ^ are for sr.ht. See golang.org/issue/32260.
1556+
const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! ~^"
15561557

15571558
func safeCgoName(s string) bool {
15581559
if s == "" {

src/go/build/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func TestShellSafety(t *testing.T) {
295295
result bool
296296
}{
297297
{"-I${SRCDIR}/../include", "/projects/src/issue 11868", "-I/projects/src/issue 11868/../include", true},
298-
{"-I${SRCDIR}", "wtf$@%", "-Iwtf$@%", true},
298+
{"-I${SRCDIR}", "~wtf$@%^", "-I~wtf$@%^", true},
299299
{"-X${SRCDIR}/1,${SRCDIR}/2", "/projects/src/issue 11868", "-X/projects/src/issue 11868/1,/projects/src/issue 11868/2", true},
300300
{"-I/tmp -I/tmp", "/tmp2", "-I/tmp -I/tmp", true},
301301
{"-I/tmp", "/tmp/[0]", "-I/tmp", true},

0 commit comments

Comments
 (0)