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
0b3e409f
Commit
0b3e409f
authored
Jul 07, 2006
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #2141: TALES doesn't traverse correctly over 'repeat' variable
parent
baa7ef3b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
18 deletions
+64
-18
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+25
-0
lib/python/Products/PageTemplates/PageTemplateFile.py
lib/python/Products/PageTemplates/PageTemplateFile.py
+0
-2
lib/python/Products/PageTemplates/TALES.py
lib/python/Products/PageTemplates/TALES.py
+1
-15
lib/python/Products/PageTemplates/tests/input/RepeatVariable.html
...on/Products/PageTemplates/tests/input/RepeatVariable.html
+10
-0
lib/python/Products/PageTemplates/tests/output/RepeatVariable.html
...n/Products/PageTemplates/tests/output/RepeatVariable.html
+21
-0
lib/python/Products/PageTemplates/tests/testExpressions.py
lib/python/Products/PageTemplates/tests/testExpressions.py
+1
-1
lib/python/Products/PageTemplates/tests/testHTMLTests.py
lib/python/Products/PageTemplates/tests/testHTMLTests.py
+3
-0
No files found.
doc/CHANGES.txt
View file @
0b3e409f
...
@@ -18,6 +18,9 @@ Zope Changes
...
@@ -18,6 +18,9 @@ Zope Changes
Bugs Fixed
Bugs Fixed
- Fix #2141: TALES doesn't traverse correctly over 'repeat'
variable
- reStructuredText/ZReST: setting raw_enabled to 0 for security
- reStructuredText/ZReST: setting raw_enabled to 0 for security
reasons
reasons
...
...
lib/python/Products/PageTemplates/Expressions.py
View file @
0b3e409f
...
@@ -28,6 +28,7 @@ from zope.proxy import removeAllProxies
...
@@ -28,6 +28,7 @@ from zope.proxy import removeAllProxies
import
zope.app.pagetemplate.engine
import
zope.app.pagetemplate.engine
import
OFS.interfaces
import
OFS.interfaces
from
MultiMapping
import
MultiMapping
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
zExceptions
import
NotFound
,
Unauthorized
from
zExceptions
import
NotFound
,
Unauthorized
from
Products.Five.browser.providerexpression
import
Z2ProviderExpression
from
Products.Five.browser.providerexpression
import
Z2ProviderExpression
...
@@ -140,8 +141,32 @@ class ZopePathExpr(PathExpr):
...
@@ -140,8 +141,32 @@ class ZopePathExpr(PathExpr):
return
1
return
1
return
0
return
0
class
SafeMapping
(
MultiMapping
):
"""Mapping with security declarations and limited method exposure.
Since it subclasses MultiMapping, this class can be used to wrap
one or more mapping objects. Restricted Python code will not be
able to mutate the SafeMapping or the wrapped mappings, but will be
able to read any value.
"""
__allow_access_to_unprotected_subobjects__
=
True
push
=
pop
=
None
_push
=
MultiMapping
.
push
_pop
=
MultiMapping
.
pop
class
ZopeContext
(
Context
):
class
ZopeContext
(
Context
):
def
__init__
(
self
,
engine
,
contexts
):
super
(
ZopeContext
,
self
).
__init__
(
engine
,
contexts
)
# wrap the top-level 'repeat' variable, as it is visible to
# restricted code
self
.
setContext
(
'repeat'
,
SafeMapping
(
self
.
repeat_vars
))
# regenerate the first scope and the scope stack after messing
# with the global context
self
.
vars
=
vars
=
contexts
.
copy
()
self
.
_vars_stack
=
[
vars
]
def
translate
(
self
,
msgid
,
domain
=
None
,
mapping
=
None
,
default
=
None
):
def
translate
(
self
,
msgid
,
domain
=
None
,
mapping
=
None
,
default
=
None
):
context
=
self
.
contexts
.
get
(
'context'
)
context
=
self
.
contexts
.
get
(
'context'
)
return
getGlobalTranslationService
().
translate
(
return
getGlobalTranslationService
().
translate
(
...
...
lib/python/Products/PageTemplates/PageTemplateFile.py
View file @
0b3e409f
...
@@ -56,8 +56,6 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
...
@@ -56,8 +56,6 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
security
.
declareProtected
(
'View management screens'
,
security
.
declareProtected
(
'View management screens'
,
'read'
,
'document_src'
)
'read'
,
'document_src'
)
_default_bindings
=
{
'name_subpath'
:
'traverse_subpath'
}
def
__init__
(
self
,
filename
,
_prefix
=
None
,
**
kw
):
def
__init__
(
self
,
filename
,
_prefix
=
None
,
**
kw
):
name
=
kw
.
pop
(
'__name__'
,
None
)
name
=
kw
.
pop
(
'__name__'
,
None
)
...
...
lib/python/Products/PageTemplates/TALES.py
View file @
0b3e409f
...
@@ -19,21 +19,7 @@ $Id$
...
@@ -19,21 +19,7 @@ $Id$
from
zope.tales.tests.simpleexpr
import
SimpleExpr
from
zope.tales.tests.simpleexpr
import
SimpleExpr
from
zope.tales.tales
import
ExpressionEngine
as
Engine
from
zope.tales.tales
import
ExpressionEngine
as
Engine
from
zope.tales.tales
import
_default
as
Default
from
zope.tales.tales
import
_default
as
Default
from
Products.PageTemplates.Expressions
import
SafeMapping
from
MultiMapping
import
MultiMapping
class
SafeMapping
(
MultiMapping
):
'''Mapping with security declarations and limited method exposure.
Since it subclasses MultiMapping, this class can be used to wrap
one or more mapping objects. Restricted Python code will not be
able to mutate the SafeMapping or the wrapped mappings, but will be
able to read any value.
'''
__allow_access_to_unprotected_subobjects__
=
1
push
=
pop
=
None
_push
=
MultiMapping
.
push
_pop
=
MultiMapping
.
pop
import
zope.deprecation
import
zope.deprecation
zope
.
deprecation
.
moved
(
"zope.tales.tales"
,
"2.12"
)
zope
.
deprecation
.
moved
(
"zope.tales.tales"
,
"2.12"
)
lib/python/Products/PageTemplates/tests/input/RepeatVariable.html
0 → 100644
View file @
0b3e409f
<html>
<body>
<ol
tal:define=
"results python:range(5)"
>
<tal:block
tal:repeat=
"items results"
>
<li
tal:define=
"odd repeat/items/odd"
tal:content=
"python:odd and 'odd' or 'even'"
>
Content
</li>
</tal:block>
</ol>
</body>
</html>
lib/python/Products/PageTemplates/tests/output/RepeatVariable.html
0 → 100644
View file @
0b3e409f
<html>
<body>
<ol>
<li>
even
</li>
<li>
odd
</li>
<li>
even
</li>
<li>
odd
</li>
<li>
even
</li>
</ol>
</body>
</html>
lib/python/Products/PageTemplates/tests/testExpressions.py
View file @
0b3e409f
...
@@ -74,7 +74,7 @@ class ExpressionTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
...
@@ -74,7 +74,7 @@ class ExpressionTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
ec
=
self
.
ec
ec
=
self
.
ec
ec
.
beginScope
()
ec
.
beginScope
()
ec
.
setRepeat
(
'loop'
,
"python:[1,2,3]"
)
ec
.
setRepeat
(
'loop'
,
"python:[1,2,3]"
)
assert
ec
.
evaluate
(
"python:repeat['loop'].
even
()"
)
assert
ec
.
evaluate
(
"python:repeat['loop'].
odd
()"
)
ec
.
endScope
()
ec
.
endScope
()
def
testWrappers
(
self
):
def
testWrappers
(
self
):
...
...
lib/python/Products/PageTemplates/tests/testHTMLTests.py
View file @
0b3e409f
...
@@ -165,6 +165,9 @@ class HTMLTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
...
@@ -165,6 +165,9 @@ class HTMLTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
def
checkImportOldStyleClass
(
self
):
def
checkImportOldStyleClass
(
self
):
self
.
assert_expected
(
self
.
folder
.
t
,
'CheckImportOldStyleClass.html'
)
self
.
assert_expected
(
self
.
folder
.
t
,
'CheckImportOldStyleClass.html'
)
def
checkRepeatVariable
(
self
):
self
.
assert_expected
(
self
.
folder
.
t
,
'RepeatVariable.html'
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
HTMLTests
,
'check'
)
return
unittest
.
makeSuite
(
HTMLTests
,
'check'
)
...
...
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