Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2e441f78
Commit
2e441f78
authored
Jul 25, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a denial-of-service attack, SF bug #443120.
Code by Evan Simpson.
parent
7cf7e7e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
Lib/cgi.py
Lib/cgi.py
+14
-4
No files found.
Lib/cgi.py
View file @
2e441f78
...
@@ -243,10 +243,13 @@ def parse_multipart(fp, pdict):
...
@@ -243,10 +243,13 @@ def parse_multipart(fp, pdict):
point in having two implementations of the same parsing algorithm.
point in having two implementations of the same parsing algorithm.
"""
"""
boundary
=
""
if
pdict
.
has_key
(
'boundary'
):
if
pdict
.
has_key
(
'boundary'
):
boundary
=
pdict
[
'boundary'
]
boundary
=
pdict
[
'boundary'
]
else
:
if
not
valid_boundary
(
boundary
):
boundary
=
""
raise
ValueError
,
(
'Invalid boundary in multipart form: %s'
%
`ib`
)
nextpart
=
"--"
+
boundary
nextpart
=
"--"
+
boundary
lastpart
=
"--"
+
boundary
+
"--"
lastpart
=
"--"
+
boundary
+
"--"
partdict
=
{}
partdict
=
{}
...
@@ -595,14 +598,18 @@ class FieldStorage:
...
@@ -595,14 +598,18 @@ class FieldStorage:
def
read_multi
(
self
,
environ
,
keep_blank_values
,
strict_parsing
):
def
read_multi
(
self
,
environ
,
keep_blank_values
,
strict_parsing
):
"""Internal: read a part that is itself multipart."""
"""Internal: read a part that is itself multipart."""
ib
=
self
.
innerboundary
if
not
valid_boundary
(
ib
):
raise
ValueError
,
(
'Invalid boundary in multipart form: %s'
%
`ib`
)
self
.
list
=
[]
self
.
list
=
[]
klass
=
self
.
FieldStorageClass
or
self
.
__class__
klass
=
self
.
FieldStorageClass
or
self
.
__class__
part
=
klass
(
self
.
fp
,
{},
self
.
innerboundary
,
part
=
klass
(
self
.
fp
,
{},
ib
,
environ
,
keep_blank_values
,
strict_parsing
)
environ
,
keep_blank_values
,
strict_parsing
)
# Throw first part away
# Throw first part away
while
not
part
.
done
:
while
not
part
.
done
:
headers
=
rfc822
.
Message
(
self
.
fp
)
headers
=
rfc822
.
Message
(
self
.
fp
)
part
=
klass
(
self
.
fp
,
headers
,
self
.
innerboundary
,
part
=
klass
(
self
.
fp
,
headers
,
ib
,
environ
,
keep_blank_values
,
strict_parsing
)
environ
,
keep_blank_values
,
strict_parsing
)
self
.
list
.
append
(
part
)
self
.
list
.
append
(
part
)
self
.
skip_lines
()
self
.
skip_lines
()
...
@@ -999,6 +1006,9 @@ def escape(s, quote=None):
...
@@ -999,6 +1006,9 @@ def escape(s, quote=None):
s
=
s
.
replace
(
'"'
,
"""
)
s
=
s
.
replace
(
'"'
,
"""
)
return
s
return
s
def
valid_boundary
(
s
,
_vb_pattern
=
"^[ -~]{0,200}[!-~]$"
):
import
re
return
re
.
match
(
_vb_pattern
,
s
)
# Invoke mainline
# Invoke mainline
# ===============
# ===============
...
...
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