mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
gc: escape unicode BOM in exported string literals
Fixes #5260. R=golang-dev, minux.ma, 0xjnml, r CC=golang-dev https://golang.org/cl/8658043
This commit is contained in:
parent
548c65a568
commit
a9f1569e7b
|
@ -443,6 +443,9 @@ Zconv(Fmt *fp)
|
|||
fmtrune(fp, '\\');
|
||||
fmtrune(fp, r);
|
||||
break;
|
||||
case 0xFEFF: // BOM, basically disallowed in source code
|
||||
fmtstrcpy(fp, "\\uFEFF");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
7
test/fixedbugs/issue5260.dir/a.go
Normal file
7
test/fixedbugs/issue5260.dir/a.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
package a
|
||||
|
||||
const BOM = "\uFEFF"
|
11
test/fixedbugs/issue5260.dir/b.go
Normal file
11
test/fixedbugs/issue5260.dir/b.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
package main
|
||||
|
||||
import "./a"
|
||||
|
||||
func main() {
|
||||
_ = a.BOM
|
||||
}
|
10
test/fixedbugs/issue5260.go
Normal file
10
test/fixedbugs/issue5260.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
// rundir
|
||||
|
||||
// Copyright 2013 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.
|
||||
|
||||
// Issue 5260: Unicode BOM in exported string constant
|
||||
// cannot be read back during package import.
|
||||
|
||||
package ignored
|
Loading…
Reference in a new issue