]> Cypherpunks repositories - gostls13.git/commitdiff
gc: diagnose \ in import path
authorRuss Cox <rsc@golang.org>
Tue, 31 Jan 2012 22:29:59 +0000 (17:29 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 31 Jan 2012 22:29:59 +0000 (17:29 -0500)
R=ken2
CC=golang-dev
https://golang.org/cl/5609044

src/cmd/gc/lex.c
test/import5.go [new file with mode: 0644]

index db6dfc3e119a4e5e81d39d2a7a13e6feb27735d0..9a21c9301089f90cf5bfcaac168f78e344a86788 100644 (file)
@@ -574,6 +574,11 @@ importfile(Val *f, int line)
                yyerror("import path contains NUL");
                errorexit();
        }
+       
+       if(strchr(f->u.sval->s, '\\')) {
+               yyerror("import path contains backslash; use slash");
+               errorexit();
+       }
 
        // The package name main is no longer reserved,
        // but we reserve the import path "main" to identify
diff --git a/test/import5.go b/test/import5.go
new file mode 100644 (file)
index 0000000..ee04170
--- /dev/null
@@ -0,0 +1,11 @@
+// errchk $G -e $D/$F.go
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// import paths are slash-separated; reject backslash
+
+package main
+
+import `net\http`  // ERROR "backslash"