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
1bebfac8
Commit
1bebfac8
authored
Jul 10, 2006
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport test of reStructuredText security fixes.
parent
0b3e409f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
lib/python/Products/ZReST/tests/test_ZReST.py
lib/python/Products/ZReST/tests/test_ZReST.py
+28
-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 @
1bebfac8
...
...
@@ -56,13 +56,40 @@ class TestZReST(unittest.TestCase):
s
=
'<h1><a id="hello-world" name="hello-world">Hello World</a></h1>'
self
.
assertEqual
(
s
in
html
,
True
)
s
=
'<h1><a id="von-v-geln-und-fen" name="von-v-geln-und-fen">Von Vgeln und fen</a></h1>'
s
=
'<h1><a id="von-v-geln-und-fen" name="von-v-geln-und-fen">'
\
'Von Vgeln und fen</a></h1>'
self
.
assertEqual
(
s
in
html
,
True
)
# ZReST should render a complete HTML document
self
.
assertEqual
(
'<html'
in
html
,
True
)
self
.
assertEqual
(
'<body>'
in
html
,
True
)
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
)
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
()
...
...
lib/python/reStructuredText/tests/testReST.py
View file @
1bebfac8
...
...
@@ -82,6 +82,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
),))
...
...
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