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
aeaf679b
Commit
aeaf679b
authored
Oct 16, 2014
by
Adam Palay
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gracefully fail when parsing xml with non-compatible string (TNL-347)
parent
9332ad47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
+8
-1
common/lib/capa/capa/responsetypes.py
+7
-1
common/lib/capa/capa/tests/test_responsetypes.py
+1
-0
No files found.
common/lib/capa/capa/responsetypes.py
View file @
aeaf679b
...
...
@@ -2111,7 +2111,13 @@ class CodeResponse(LoncapaResponse):
except
etree
.
XMLSyntaxError
as
_err
:
# If `html` contains attrs with no values, like `controls` in <audio controls src='smth'/>,
# XML parser will raise exception, so wee fallback to html5parser, which will set empty "" values for such attrs.
parsed
=
html5lib
.
parseFragment
(
msg
,
treebuilder
=
'lxml'
,
namespaceHTMLElements
=
False
)
try
:
parsed
=
html5lib
.
parseFragment
(
msg
,
treebuilder
=
'lxml'
,
namespaceHTMLElements
=
False
)
except
ValueError
:
# the parsed message might contain strings that are not
# xml compatible, in which case, throw the error message
parsed
=
False
if
not
parsed
:
log
.
error
(
"Unable to parse external grader message as valid"
" XML: score_msg['msg']=
%
s"
,
msg
)
...
...
common/lib/capa/capa/tests/test_responsetypes.py
View file @
aeaf679b
...
...
@@ -1006,6 +1006,7 @@ class CodeResponseTest(ResponseTest):
invalid_grader_msgs
=
[
'<audio'
,
# invalid XML and HTML5
'<p>
\b
</p>'
,
# invalid special character
]
answer_ids
=
sorted
(
self
.
problem
.
get_question_answers
())
...
...
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