Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
Zope
Commits
8c326d42
Commit
8c326d42
authored
18 years ago
by
Tres Seaver
Browse files
Options
Download
Email Patches
Plain Diff
Backport tests for ZReST / reStructuredText security fixes.
parent
75d308f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
1 deletion
+56
-1
lib/python/Products/ZReST/tests/test_ZReST.py
lib/python/Products/ZReST/tests/test_ZReST.py
+30
-0
lib/python/docutils/parsers/rst/directives/misc.py
lib/python/docutils/parsers/rst/directives/misc.py
+0
-1
lib/python/reStructuredText/tests/testReST.py
lib/python/reStructuredText/tests/testReST.py
+26
-0
No files found.
lib/python/Products/ZReST/tests/test_ZReST.py
View file @
8c326d42
...
...
@@ -29,6 +29,36 @@ class TestZReST(unittest.TestCase):
self
.
failIf
(
'IGNORE ME'
in
resty
.
index_html
())
def
test_include_directive_raises
(
self
):
resty
=
self
.
_makeOne
()
resty
.
source
=
'hello world
\n
.. include:: /etc/passwd'
self
.
assertRaises
(
NotImplementedError
,
resty
.
render
)
def
test_raw_directive_disabled
(
self
):
EXPECTED
=
'<h1>HELLO WORLD</h1>'
resty
=
self
.
_makeOne
()
resty
.
source
=
'.. raw:: html
\n\n
%s
\n
'
%
EXPECTED
result
=
resty
.
render
()
# don't raise, but don't work either
self
.
failIf
(
EXPECTED
in
result
)
self
.
failUnless
(
""raw" directive disabled"
in
result
)
from
cgi
import
escape
self
.
failUnless
(
escape
(
EXPECTED
)
in
result
)
def
test_raw_directive_file_directive_raises
(
self
):
resty
=
self
.
_makeOne
()
resty
.
source
=
'.. raw:: html
\n
:file: inclusion.txt'
self
.
assertRaises
(
NotImplementedError
,
resty
.
render
)
def
test_raw_directive_url_directive_raises
(
self
):
resty
=
self
.
_makeOne
()
resty
.
source
=
'.. raw:: html
\n
:url: http://www.zope.org/'
self
.
assertRaises
(
NotImplementedError
,
resty
.
render
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestZReST
))
...
...
This diff is collapsed.
Click to expand it.
lib/python/docutils/parsers/rst/directives/misc.py
View file @
8c326d42
...
...
@@ -42,7 +42,6 @@ def raw(name, arguments, options, content, lineno,
"""
if
options
.
has_key
(
'file'
)
or
options
.
has_key
(
'url'
):
raise
NotImplementedError
,
'File inclusion not allowed!'
print
2
if
(
not
state
.
document
.
settings
.
raw_enabled
or
(
not
state
.
document
.
settings
.
file_insertion_enabled
and
(
options
.
has_key
(
'file'
)
or
options
.
has_key
(
'url'
)))
):
...
...
This diff is collapsed.
Click to expand it.
lib/python/reStructuredText/tests/testReST.py
View file @
8c326d42
...
...
@@ -26,6 +26,32 @@ text
self
.
assertEquals
(
output
,
expected
)
def
test_include_directive_raises
(
self
):
source
=
'hello world
\n
.. include:: /etc/passwd'
self
.
assertRaises
(
NotImplementedError
,
HTML
,
source
)
def
test_raw_directive_disabled
(
self
):
EXPECTED
=
'<h1>HELLO WORLD</h1>'
source
=
'.. raw:: html
\n\n
%s
\n
'
%
EXPECTED
result
=
HTML
(
source
)
# don't raise, but don't work either
self
.
failIf
(
EXPECTED
in
result
)
self
.
failUnless
(
""raw" directive disabled"
in
result
)
from
cgi
import
escape
self
.
failUnless
(
escape
(
EXPECTED
)
in
result
)
def
test_raw_directive_file_option_raises
(
self
):
source
=
'.. raw:: html
\n
:file: inclusion.txt'
self
.
assertRaises
(
NotImplementedError
,
HTML
,
source
)
def
test_raw_directive_url_option_raises
(
self
):
source
=
'.. raw:: html
\n
:url: http://www.zope.org'
self
.
assertRaises
(
NotImplementedError
,
HTML
,
source
)
def
test_suite
():
from
unittest
import
TestSuite
,
makeSuite
return
TestSuite
((
makeSuite
(
TestReST
),))
This diff is collapsed.
Click to expand it.
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