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
f738b87c
Commit
f738b87c
authored
May 01, 2006
by
Chris Withers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #2061: Fix problems where windows line endings are passed to restricted code compilers.
parent
a8bc52fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/RestrictedPython/RCompile.py
lib/python/RestrictedPython/RCompile.py
+4
-0
lib/python/RestrictedPython/tests/testRestrictions.py
lib/python/RestrictedPython/tests/testRestrictions.py
+29
-0
No files found.
doc/CHANGES.txt
View file @
f738b87c
...
...
@@ -18,6 +18,9 @@ Zope Changes
Bugs fixed
- Collector #2061: Fix problems where windows line endings are passed
to restricted code compilers.
- Collector #2072: Applied patch to fix problem with overly restrictive
__bobo_traverse__ security and tests.
...
...
lib/python/RestrictedPython/RCompile.py
View file @
f738b87c
...
...
@@ -42,6 +42,8 @@ class RestrictedCompileMode(AbstractCompileMode):
# See concrete subclasses below.
def
__init__
(
self
,
source
,
filename
):
if
source
:
source
=
'
\
n
'
.
join
(
source
.
splitlines
())
self
.
rm
=
RestrictionMutator
()
AbstractCompileMode
.
__init__
(
self
,
source
,
filename
)
...
...
@@ -206,6 +208,8 @@ class RFunction(RModule):
def
__init__
(
self
,
p
,
body
,
name
,
filename
,
globals
):
self
.
params
=
p
if
body
:
body
=
'
\
n
'
.
join
(
body
.
splitlines
())
self
.
body
=
body
self
.
name
=
name
self
.
globals
=
globals
or
[]
...
...
lib/python/RestrictedPython/tests/testRestrictions.py
View file @
f738b87c
...
...
@@ -499,6 +499,35 @@ class RestrictionTests(unittest.TestCase):
self
.
assertRaises
(
SyntaxError
,
compile_restricted
,
err
,
"<string>"
,
"exec"
)
# these two tests check that source code with Windows line
# endings still works.
def
checkLineEndingsRFunction
(
self
):
from
RestrictedPython.RCompile
import
RFunction
gen
=
RFunction
(
p
=
''
,
body
=
'# testing
\
r
\
n
print "testing"
\
r
\
n
return printed
\
n
'
,
name
=
'test'
,
filename
=
'<test>'
,
globals
=
(),
)
gen
.
mode
=
'exec'
# if the source has any line ending other than \n by the time
# parse() is called, then you'll get a syntax error.
gen
.
parse
()
def
checkLineEndingsRestrictedCompileMode
(
self
):
from
RestrictedPython.RCompile
import
RestrictedCompileMode
gen
=
RestrictedCompileMode
(
'# testing
\
r
\
n
print "testing"
\
r
\
n
return printed
\
n
'
,
'<testing>'
)
gen
.
mode
=
'exec'
# if the source has any line ending other than \n by the time
# parse() is called, then you'll get a syntax error.
gen
.
parse
()
create_rmodule
()
def
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