1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:44:41 -07: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:
Volker Dobler 2013-04-11 11:45:18 -07:00 committed by Rob Pike
parent 548c65a568
commit a9f1569e7b
4 changed files with 31 additions and 0 deletions

View File

@ -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;

View 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"

View 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
}

View 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