Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3194e544
Commit
3194e544
authored
Aug 28, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #805 from edx/ned/fix-allow-comments-in-capa-xml
Keep comments in capa XML from causing failures
parents
77abfbf4
2c544cb0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
common/lib/capa/capa/capa_problem.py
+7
-0
common/lib/capa/capa/tests/test_html_render.py
+20
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
3194e544
...
@@ -555,6 +555,13 @@ class LoncapaProblem(object):
...
@@ -555,6 +555,13 @@ class LoncapaProblem(object):
Used by get_html.
Used by get_html.
'''
'''
if
not
isinstance
(
problemtree
.
tag
,
basestring
):
# Comment and ProcessingInstruction nodes are not Elements,
# and we're ok leaving those behind.
# BTW: etree gives us no good way to distinguish these things
# other than to examine .tag to see if it's a string. :(
return
if
(
problemtree
.
tag
==
'script'
and
problemtree
.
get
(
'type'
)
if
(
problemtree
.
tag
==
'script'
and
problemtree
.
get
(
'type'
)
and
'javascript'
in
problemtree
.
get
(
'type'
)):
and
'javascript'
in
problemtree
.
get
(
'type'
)):
# leave javascript intact.
# leave javascript intact.
...
...
common/lib/capa/capa/tests/test_html_render.py
View file @
3194e544
...
@@ -226,6 +226,26 @@ class CapaHtmlRenderTest(unittest.TestCase):
...
@@ -226,6 +226,26 @@ class CapaHtmlRenderTest(unittest.TestCase):
span_element
=
rendered_html
.
find
(
'span'
)
span_element
=
rendered_html
.
find
(
'span'
)
self
.
assertEqual
(
span_element
.
get
(
'attr'
),
"TEST"
)
self
.
assertEqual
(
span_element
.
get
(
'attr'
),
"TEST"
)
def
test_xml_comments_and_other_odd_things
(
self
):
# Comments and processing instructions should be skipped.
xml_str
=
textwrap
.
dedent
(
"""
\
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html [
<!ENTITY
%
wacky "lxml.etree is wacky!">
]>
<problem>
<!-- A commment. -->
<?ignore this processing instruction. ?>
</problem>
"""
)
# Create the problem
problem
=
new_loncapa_problem
(
xml_str
)
# Render the HTML
the_html
=
problem
.
get_html
()
self
.
assertRegexpMatches
(
the_html
,
r"<div>\s+</div>"
)
def
_create_test_file
(
self
,
path
,
content_str
):
def
_create_test_file
(
self
,
path
,
content_str
):
test_fp
=
self
.
system
.
filestore
.
open
(
path
,
"w"
)
test_fp
=
self
.
system
.
filestore
.
open
(
path
,
"w"
)
test_fp
.
write
(
content_str
)
test_fp
.
write
(
content_str
)
...
...
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