Skip to content

Commit

Permalink
go/build: allow ~ and ^ in #cgo directives for sr.ht import paths
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
eliasnaur committed Oct 9, 2019
1 parent a38a917 commit 0b204f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/go/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,8 @@ func (ctxt *Context) makePathsAbsolute(args []string, srcDir string) {
// The @ is for OS X. See golang.org/issue/13720.
// The % is for Jenkins. See golang.org/issue/16959.
// The ! is because module paths may use them. See golang.org/issue/26716.
const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! "
// The ~ and ^ are for sr.ht. See golang.org/issue/32260.
const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! ~^"

func safeCgoName(s string) bool {
if s == "" {
Expand Down
2 changes: 1 addition & 1 deletion src/go/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestShellSafety(t *testing.T) {
result bool
}{
{"-I${SRCDIR}/../include", "/projects/src/issue 11868", "-I/projects/src/issue 11868/../include", true},
{"-I${SRCDIR}", "wtf$@%", "-Iwtf$@%", true},
{"-I${SRCDIR}", "~wtf$@%^", "-I~wtf$@%^", true},
{"-X${SRCDIR}/1,${SRCDIR}/2", "/projects/src/issue 11868", "-X/projects/src/issue 11868/1,/projects/src/issue 11868/2", true},
{"-I/tmp -I/tmp", "/tmp2", "-I/tmp -I/tmp", true},
{"-I/tmp", "/tmp/[0]", "-I/tmp", true},
Expand Down

0 comments on commit 0b204f9

Please sign in to comment.