Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
8a8ea9b0
Commit
8a8ea9b0
authored
Dec 27, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1797: unicode safety
parent
4c3767ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
29 deletions
+17
-29
lib/python/ZPublisher/HTTPRequest.py
lib/python/ZPublisher/HTTPRequest.py
+8
-5
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+9
-24
No files found.
lib/python/ZPublisher/HTTPRequest.py
View file @
8a8ea9b0
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__version__
=
'$Revision: 1.4
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
1
$'
[
11
:
-
2
]
import
regex
,
re
,
sys
,
os
,
string
,
urllib
from
string
import
lower
,
atoi
,
rfind
,
split
,
strip
,
join
,
upper
,
find
...
...
@@ -871,14 +871,14 @@ class HTTPRequest(BaseRequest):
result
=
"<h3>form</h3><table>"
row
=
'<tr valign="top" align="left"><th>%s</th><td>%s</td></tr>'
for
k
,
v
in
self
.
form
.
items
():
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
v
))
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
repr
(
v
)
))
result
=
result
+
"</table><h3>cookies</h3><table>"
for
k
,
v
in
self
.
cookies
.
items
():
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
v
))
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
repr
(
v
)
))
result
=
result
+
"</table><h3>other</h3><table>"
for
k
,
v
in
self
.
other
.
items
():
if
k
in
(
'PARENTS'
,
'RESPONSE'
):
continue
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
v
))
result
=
result
+
row
%
(
html_quote
(
k
),
html_quote
(
repr
(
v
)
))
for
n
in
"0123456789"
:
key
=
"URL%s"
%
n
...
...
@@ -1051,7 +1051,10 @@ class record:
L1.sort()
return join(map(lambda item: "
%
s
:
%
s
" %item, L1), "
,
")
__repr__ = __str__
def __repr__(self):
L1 = self.__dict__.items()
L1.sort()
return join(map(lambda item: "
%
s
:
%
s
" %item, repr(L1)), "
,
")
# Flags
SEQUENCE=1
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
8a8ea9b0
...
...
@@ -84,8 +84,8 @@
##############################################################################
'''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.
39 2000/12/15 16:14:01 ev
an Exp $'''
__version__
=
'$Revision: 1.
39
$'
[
11
:
-
2
]
$Id: HTTPResponse.py,v 1.
40 2000/12/27 16:36:12 bri
an Exp $'''
__version__
=
'$Revision: 1.
40
$'
[
11
:
-
2
]
import
string
,
types
,
sys
,
regex
,
re
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
...
...
@@ -161,8 +161,6 @@ status_codes['redirect']=300
start_of_header_search
=
re
.
compile
(
'(<head[^>]*>)'
,
re
.
IGNORECASE
).
search
#end_of_header_search=regex.compile('</head>',regex.casefold).search
accumulate_header
=
{
'set-cookie'
:
1
}.
has_key
class
HTTPResponse
(
BaseResponse
):
...
...
@@ -578,7 +576,7 @@ class HTTPResponse(BaseResponse):
"
\
\
(#[^
\
000
-
\
"
\
\
#<>]*
\
\
)?"
"$"
).
match
,
tag_search
=
re
gex
.
compile
(
'[a-zA-Z]>'
).
search
,
tag_search
=
re
.
compile
(
'[a-zA-Z]>'
).
search
,
abort
=
1
):
if
type
(
info
)
is
type
(())
and
len
(
info
)
==
3
:
t
,
v
,
tb
=
info
...
...
@@ -627,7 +625,11 @@ class HTTPResponse(BaseResponse):
except
:
pass
b
=
v
if
isinstance
(
b
,
Exception
):
b
=
str
(
b
)
if
isinstance
(
b
,
Exception
):
try
:
b
=
str
(
b
)
except
:
b
=
'<unprintable %s object>'
%
type
(
b
).
__name__
if
fatal
and
t
is
SystemExit
and
v
.
code
==
0
:
tb
=
self
.
setBody
(
...
...
@@ -637,7 +639,7 @@ class HTTPResponse(BaseResponse):
is_error
=
1
)
#elif 1: self.setBody(v)
elif
type
(
b
)
is
not
types
.
StringType
or
tag_search
(
b
)
<
0
:
elif
type
(
b
)
is
not
types
.
StringType
or
tag_search
(
b
)
is
None
:
tb
=
self
.
setBody
(
(
str
(
t
),
'Sorry, a Zope error occurred.<p>'
+
...
...
@@ -696,23 +698,6 @@ class HTTPResponse(BaseResponse):
c
=
'text/plain'
self
.
setHeader
(
'content-type'
,
c
)
# Don't try to fix user HTML!
#else:
# isHTML = split(headers.get('content-type', ''),
# ';')[0] == 'text/html'
#if isHTML and end_of_header_search(self.body) < 0:
# lhtml=html_search(body)
# if lhtml >= 0:
# lhtml=lhtml+6
# body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:])
# elif contHTML:
# body='<html><head></head>\n' + body
# else:
# body='<html><head></head>\n' + body + '\n</html>\n'
# self.setBody(body)
# body=self.body
if
not
headers
.
has_key
(
'content-length'
)
and
\
not
headers
.
has_key
(
'transfer-encoding'
):
self
.
setHeader
(
'content-length'
,
len
(
body
))
...
...
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