Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
5cdb7ba3
Commit
5cdb7ba3
authored
Jan 15, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reject invalid hex/unicode escape sequences instead of letting them crash the compiler
parent
7f45b0b7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
5 deletions
+50
-5
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+11
-5
tests/errors/invalid_hex_escape0.pyx
tests/errors/invalid_hex_escape0.pyx
+6
-0
tests/errors/invalid_hex_escape1.pyx
tests/errors/invalid_hex_escape1.pyx
+6
-0
tests/errors/invalid_uescape.pyx
tests/errors/invalid_uescape.pyx
+6
-0
tests/errors/invalid_uescape0.pyx
tests/errors/invalid_uescape0.pyx
+6
-0
tests/errors/invalid_uescape2.pyx
tests/errors/invalid_uescape2.pyx
+6
-0
tests/run/strliterals.pyx
tests/run/strliterals.pyx
+9
-0
No files found.
Cython/Compiler/Parsing.py
View file @
5cdb7ba3
...
...
@@ -782,13 +782,19 @@ def p_string_literal(s, kind_override=None):
elif
c
==
u'
\
n
'
:
pass
elif
c
==
u'x'
:
chars
.
append_charval
(
int
(
systr
[
2
:],
16
)
)
if
len
(
systr
)
==
4
:
chars
.
append_charval
(
int
(
systr
[
2
:],
16
)
)
else
:
s
.
error
(
"Invalid hex escape '%s'"
%
systr
,
pos
=
s
.
position
())
elif
c
in
u'Uu'
:
if
kind
in
(
'u'
,
''
):
chrval
=
int
(
systr
[
2
:],
16
)
if
chrval
>
1114111
:
# sys.maxunicode:
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
,
pos
=
pos
)
if
len
(
systr
)
in
(
6
,
10
):
chrval
=
int
(
systr
[
2
:],
16
)
if
chrval
>
1114111
:
# sys.maxunicode:
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
,
pos
=
pos
)
else
:
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
,
pos
=
s
.
position
())
else
:
# unicode escapes in plain byte strings are not unescaped
chrval
=
None
...
...
tests/errors/invalid_hex_escape0.pyx
0 → 100644
View file @
5cdb7ba3
'
\
x
'
_ERRORS = '''
2:1: Invalid hex escape '
\
x
'
'''
tests/errors/invalid_hex_escape1.pyx
0 → 100644
View file @
5cdb7ba3
'
\
x
1
'
_ERRORS
=
'''
2:1: Invalid hex escape '
\
x
'
'''
tests/errors/invalid_uescape.pyx
0 → 100644
View file @
5cdb7ba3
u'
\
uXYZ
'
_ERRORS = '''
2:2: Invalid unicode escape '
\
u'
'''
tests/errors/invalid_uescape0.pyx
0 → 100644
View file @
5cdb7ba3
u'
\
u
'
_ERRORS = '''
2:1: Invalid unicode escape '
\
u'
'''
tests/errors/invalid_uescape2.pyx
0 → 100644
View file @
5cdb7ba3
u'
\
u
12
'
_ERRORS
=
'''
2:1: Invalid unicode escape '
\
u
'
'''
tests/run/strliterals.pyx
View file @
5cdb7ba3
...
...
@@ -125,6 +125,13 @@ __doc__ = ur"""
>>> len(uresc)
9
>>> bytes_uescape
b'\\u1234\\U12345678\\u\\u1\\u12\\uX'
>>> bytes_uescape == b'\\u1234\\U12345678\\u\\u1\\u12\\uX'
True
>>> len(bytes_uescape)
28
>>> newlines == "Aaa\n"
True
...
...
@@ -165,6 +172,8 @@ sresc = r'\12\'\"\\'
bresc
=
br'\12\'\"\\'
uresc
=
ur'\12\'\"\\'
bytes_uescape
=
b'
\
u1234
\
U12345678
\
u
\
u1
\
u
12
\
uX
'
newlines = "Aaa
\
n
"
# T640, long literals with escapes
...
...
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