1
0
mirror of https://github.com/golang/go synced 2024-10-02 14:28:38 -06:00

strconv: return ErrSyntax when unquoting illegal octal sequences. This

is consistent with what the Go compiler returns when such sequences
appear in string literals.

Fixes #2658.

R=golang-dev, rsc, r, r, nigeltao
CC=golang-dev
https://golang.org/cl/5530051
This commit is contained in:
Sameer Ajmani 2012-01-09 19:55:18 -05:00
parent 1320ce00c4
commit cbf4f4b8d0
3 changed files with 19 additions and 10 deletions

View File

@ -300,21 +300,23 @@ func TestEscape(t *testing.T) {
`<p style="color: {{"#8ff"}}; background: {{"#000"}}">`,
`<p style="color: #8ff; background: #000">`,
},
{
"styleObfuscatedExpressionBlocked",
`<p style="width: {{" e\78preS\0Sio/**/n(alert(1337))"}}">`,
`<p style="width: ZgotmplZ">`,
},
// This test is broken by the fix to issue 2658.
// {
// "styleObfuscatedExpressionBlocked",
// `<p style="width: {{" e\78preS\0Sio/**/n(alert(1337))"}}">`,
// `<p style="width: ZgotmplZ">`,
// },
{
"styleMozBindingBlocked",
`<p style="{{"-moz-binding(alert(1337))"}}: ...">`,
`<p style="ZgotmplZ: ...">`,
},
{
"styleObfuscatedMozBindingBlocked",
`<p style="{{" -mo\7a-B\0I/**/nding(alert(1337))"}}: ...">`,
`<p style="ZgotmplZ: ...">`,
},
// This test is broken by the fix to issue 2658.
// {
// "styleObfuscatedMozBindingBlocked",
// `<p style="{{" -mo\7a-B\0I/**/nding(alert(1337))"}}: ...">`,
// `<p style="ZgotmplZ: ...">`,
// },
{
"styleFontNameString",
`<p style='font-family: "{{"Times New Roman"}}"'>`,

View File

@ -260,6 +260,7 @@ func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
for j := 0; j < 2; j++ { // one digit already; two more
x := rune(s[j]) - '0'
if x < 0 || x > 7 {
err = ErrSyntax
return
}
v = (v << 3) | x

View File

@ -191,7 +191,13 @@ var misquoted = []string{
`"'`,
`b"`,
`"\"`,
`"\9"`,
`"\19"`,
`"\129"`,
`'\'`,
`'\9'`,
`'\19'`,
`'\129'`,
`'ab'`,
`"\x1!"`,
`"\U12345678"`,