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
2207e04d
Commit
2207e04d
authored
Oct 11, 2005
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #1914: Harden 'call_with_ns' against namespaces from other callers.
o Forward-port from 2.7 branch.
parent
18e43813
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
doc/CHANGES.txt
doc/CHANGES.txt
+4
-0
lib/python/Products/PageTemplates/ZRPythonExpr.py
lib/python/Products/PageTemplates/ZRPythonExpr.py
+5
-2
lib/python/Products/PageTemplates/tests/testZRPythonExpr.py
lib/python/Products/PageTemplates/tests/testZRPythonExpr.py
+48
-0
No files found.
doc/CHANGES.txt
View file @
2207e04d
...
...
@@ -33,6 +33,10 @@ Zope Changes
Bugs Fixed
- Collector #1914: Hardened 'call_with_ns' (in
'Products.PageTemplates.ZRPythonExpr') against namespaces from other
callers than page templates.
- Collector #1490: Added a new zope.conf option to control the
character set used to encode unicode data that reaches
ZPublisher without any specified encoding.
...
...
lib/python/Products/PageTemplates/ZRPythonExpr.py
View file @
2207e04d
...
...
@@ -62,8 +62,11 @@ class Rtd(RestrictedDTML, TemplateDict):
def
call_with_ns
(
f
,
ns
,
arg
=
1
):
td
=
Rtd
()
td
.
this
=
ns
[
'here'
]
td
.
_push
(
ns
[
'request'
])
# prefer 'context' to 'here'; fall back to 'None'
this
=
ns
.
get
(
'context'
,
ns
.
get
(
'here'
))
td
.
this
=
this
request
=
ns
.
get
(
'request'
,
{})
td
.
_push
(
request
)
td
.
_push
(
InstanceDict
(
td
.
this
,
td
))
td
.
_push
(
ns
)
try
:
...
...
lib/python/Products/PageTemplates/tests/testZRPythonExpr.py
0 → 100644
View file @
2207e04d
""" Unit tests for Products.PageTemplates.ZRPythonExpr
$Id
"""
import
unittest
class
MiscTests
(
unittest
.
TestCase
):
def
test_call_with_ns_prefer_context_to_here
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
context
=
[
'context'
]
here
=
[
'here'
]
request
=
{
'request'
:
1
}
names
=
{
'context'
:
context
,
'here'
:
here
,
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
context
,
result
)
def
test_call_with_ns_no_context_or_here
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
request
=
{
'request'
:
1
}
names
=
{
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
None
,
result
)
def
test_call_with_ns_no_request
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
context
=
[
'context'
]
here
=
[
'here'
]
names
=
{
'context'
:
context
,
'here'
:
here
}
def
_find_request
(
td
):
ns
=
td
.
_pop
()
# peel off 'ns'
instance_dict
=
td
.
_pop
()
# peel off InstanceDict
request
=
td
.
_pop
()
td
.
_push
(
request
)
td
.
_push
(
instance_dict
)
td
.
_push
(
ns
)
return
request
result
=
call_with_ns
(
_find_request
,
names
)
self
.
assertEqual
(
result
,
{})
def
test_suite
():
return
unittest
.
makeSuite
(
MiscTests
)
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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