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
1145fc9e
Commit
1145fc9e
authored
May 30, 2003
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for objects becoming publishable under Python2.2 due to docstrings
being added to built-in types.
parent
3d3f38c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+36
-1
No files found.
lib/python/ZPublisher/BaseRequest.py
View file @
1145fc9e
...
...
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__version__
=
'$Revision: 1.5
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
1
$'
[
11
:
-
2
]
from
urllib
import
quote
import
xmlrpc
...
...
@@ -344,6 +344,17 @@ class BaseRequest:
"published."
%
URL
)
# Hack for security: in Python 2.2.2, most built-in types
# gained docstrings that they didn't have before. That caused
# certain mutable types (dicts, lists) to become publishable
# when they shouldn't be. The following check makes sure that
# the right thing happens in both 2.2.2+ and earlier versions.
if
not
typeCheck
(
subobject
):
return
response
.
debugError
(
"The object at %s is not publishable."
%
URL
)
r
=
getattr
(
subobject
,
'__roles__'
,
UNSPECIFIED_ROLES
)
if
r
is
not
UNSPECIFIED_ROLES
:
roles
=
r
...
...
@@ -490,3 +501,27 @@ def old_validation(groups, request, auth,
"""<strong>You are not authorized to access this resource"""
)
return
None
# This mapping contains the built-in types that gained docstrings
# between Python 2.1 and 2.2.2. By specifically checking for these
# types during publishing, we ensure the same publishing rules in
# both versions. The downside is that this needs to be extended as
# new built-in types are added and future Python versions are
# supported. That happens rarely enough that hopefully we'll be on
# Zope 3 by then :)
import
types
itypes
=
{}
for
name
in
(
'NoneType'
,
'IntType'
,
'LongType'
,
'FloatType'
,
'StringType'
,
'BufferType'
,
'TupleType'
,
'ListType'
,
'DictType'
,
'XRangeType'
,
'SliceType'
,
'EllipsisType'
,
'UnicodeType'
,
'CodeType'
,
'TracebackType'
,
'FrameType'
,
'DictProxyType'
):
if
hasattr
(
types
,
name
):
itypes
[
getattr
(
types
,
name
)]
=
0
def
typeCheck
(
obj
,
deny
=
itypes
):
# Return true if its ok to publish the type, false otherwise.
return
deny
.
get
(
type
(
obj
),
1
)
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