Skip to content

Commit

Permalink
Merge pull request #255 from collective/maurits/cmfplone-issue-3209-l…
Browse files Browse the repository at this point in the history
…xml-2x

Field xml editor: do not resolve entitities [2.x]
  • Loading branch information
mauritsvanrees committed Nov 17, 2020
2 parents cfea609 + 602adbd commit 54ef8dc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -54,7 +54,8 @@ before_script:
- sleep 3
script:
# Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout.
- python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis
# Do not run it on Plone 5.0 either, because there is too often yet another version conflict on install.
- python --version 2> /dev/stdout | grep 3.6 || echo $PLONE_VERSION | grep 5.0 || bin/code-analysis
- bin/test --all $TEST_OPTIONS
after_success:
- bin/createcoverage -t '--all $TEST_OPTIONS'
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Expand Up @@ -37,3 +37,4 @@ eggs =
[versions]
# Don't use a released version of collective.easyforms
collective.easyforms =
Pillow = 3.3.3
2 changes: 2 additions & 0 deletions news/3209.bugfix
@@ -0,0 +1,2 @@
For increased security, in the modeleditor do not resolve entities, and remove processing instructions.
[maurits]
6 changes: 5 additions & 1 deletion src/collective/easyform/browser/fields.py
Expand Up @@ -155,9 +155,13 @@ def __call__(self):

source = self.request.form.get("source")
if source:
# Some safety measures.
# We do not want to load entities, especially file:/// entities.
# Also discard processing instructions.
parser = etree.XMLParser(resolve_entities=False, remove_pis=True)
# Is it valid XML?
try:
root = etree.fromstring(source)
root = etree.fromstring(source, parser=parser)
except etree.XMLSyntaxError as e:
return dumps(
{
Expand Down
11 changes: 8 additions & 3 deletions tests-5.0.x.cfg
Expand Up @@ -5,9 +5,12 @@ extends =
https://raw.githubusercontent.com/plone/plone.app.robotframework/master/versions.cfg
base.cfg

parts +=
parts=
instance
test
code-analysis
# This too often fails because of a version conflict:
# code-analysis
i18ndude
createcoverage

package-name = collective.easyform
Expand All @@ -17,8 +20,10 @@ test-eggs =
[versions]
setuptools =
zc.buildout =
check-manifest = 0.41
coverage = >=3.7
plone.app.mosaic =
plone.app.robotframework = 1.5.0
plone.formwidget.recaptcha = 2.1.0
pycodestyle = 2.5.0
pycodestyle = 2.5.0
flake8 = 3.7.9
1 change: 1 addition & 0 deletions tests-5.1.x.cfg
Expand Up @@ -17,6 +17,7 @@ test-eggs =
[versions]
setuptools =
zc.buildout =
check-manifest = 0.41
coverage = >=3.7
plone.app.mosaic =
plone.app.robotframework = 1.5.0
Expand Down

0 comments on commit 54ef8dc

Please sign in to comment.