Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
ace5269d
Commit
ace5269d
authored
Jun 09, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/scanner: report illegal escape sequences
R=golang-dev, r CC=golang-dev
https://golang.org/cl/1636043
parent
4032b7c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
21 deletions
+30
-21
test.sh
src/cmd/gofmt/test.sh
+1
-1
scanner.go
src/pkg/go/scanner/scanner.go
+29
-20
No files found.
src/cmd/gofmt/test.sh
View file @
ace5269d
...
...
@@ -36,7 +36,7 @@ apply1() {
# the following files are skipped because they are test cases
# for syntax errors and thus won't parse in the first place:
case
`
basename
"
$F
"
`
in
func3.go
|
const2.go
|
\
func3.go
|
const2.go
|
char_lit1.go
|
\
bug014.go
|
bug050.go
|
bug068.go
|
bug083.go
|
bug088.go
|
\
bug106.go
|
bug121.go
|
bug125.go
|
bug133.go
|
bug160.go
|
\
bug163.go
|
bug166.go
|
bug169.go
|
bug217.go
|
bug222.go
|
\
...
...
src/pkg/go/scanner/scanner.go
View file @
ace5269d
...
...
@@ -345,34 +345,43 @@ exit:
}
func
(
S
*
Scanner
)
scanDigits
(
base
,
length
int
)
{
for
length
>
0
&&
digitVal
(
S
.
ch
)
<
base
{
S
.
next
()
length
--
}
if
length
>
0
{
S
.
error
(
S
.
pos
,
"illegal char escape"
)
}
}
func
(
S
*
Scanner
)
scanEscape
(
quote
int
)
{
pos
:=
S
.
pos
ch
:=
S
.
ch
S
.
next
()
switch
ch
{
var
i
,
base
,
max
uint32
switch
S
.
ch
{
case
'a'
,
'b'
,
'f'
,
'n'
,
'r'
,
't'
,
'v'
,
'\\'
,
quote
:
// nothing to do
S
.
next
()
return
case
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
:
S
.
scanDigits
(
8
,
3
-
1
)
// 1 char read already
i
,
base
,
max
=
3
,
8
,
255
case
'x'
:
S
.
scanDigits
(
16
,
2
)
S
.
next
()
i
,
base
,
max
=
2
,
16
,
255
case
'u'
:
S
.
scanDigits
(
16
,
4
)
S
.
next
()
i
,
base
,
max
=
4
,
16
,
unicode
.
MaxRune
case
'U'
:
S
.
scanDigits
(
16
,
8
)
S
.
next
()
i
,
base
,
max
=
8
,
16
,
unicode
.
MaxRune
default
:
S
.
error
(
pos
,
"illegal char escape"
)
S
.
next
()
// always make progress
S
.
error
(
pos
,
"unknown escape sequence"
)
return
}
var
x
uint32
for
;
i
>
0
;
i
--
{
d
:=
uint32
(
digitVal
(
S
.
ch
))
if
d
>
base
{
S
.
error
(
S
.
pos
,
"illegal character in escape sequence"
)
return
}
x
=
x
*
base
+
d
S
.
next
()
}
if
x
>
max
||
0xd800
<=
x
&&
x
<
0xe000
{
S
.
error
(
pos
,
"escape sequence is invalid Unicode code point"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment