Skip to content

Commit

Permalink
Apply isURLInPortal fix from https://pypi.python.org/pypi/Products.Pl…
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Sep 10, 2015
1 parent 43a10d9 commit 1845b0a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Changelog
5.0rc2 (unreleased)
-------------------

- Apply isURLInPortal fix from https://pypi.python.org/pypi/Products.PloneHotfix20150910
[vangheem]

- Do not bother additional CRSF protection for addMember since all public
users get same CSRF token and the method should be unpublished.
See https://pypi.python.org/pypi/Products.PloneHotfix20150910
Expand Down
3 changes: 3 additions & 0 deletions Products/CMFPlone/URLTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def isURLInPortal(self, url, context=None):
"""
# sanitize url
url = re.sub('^[\x00-\x20]+', '', url).strip()
if ('<script' in url or '%3Cscript' in url or 'javascript:' in url or
'javascript%3A' in url):
return False

p_url = self()

Expand Down
9 changes: 9 additions & 0 deletions Products/CMFPlone/tests/testURLTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,12 @@ def test_isURLInPortalExternal(self):
self.assertFalse(iURLiP('http://external4/other'))
self.assertFalse(iURLiP('http://external5'))
self.assertFalse(iURLiP('http://external11'))

def test_script_tag_url_not_in_portal(self):
self.assertFalse(self.portal.portal_url.isURLInPortal('<script>alert("hi");</script>'))
self.assertFalse(
self.portal.portal_url.isURLInPortal('%3Cscript%3Ealert(%22hi%22)%3B%3C%2Fscript%3E'))

def test_inline_url_not_in_portal(self):
self.assertFalse(self.portal.portal_url.isURLInPortal('javascript%3Aalert(3)'))
self.assertFalse(self.portal.portal_url.isURLInPortal('javascript:alert(3)'))

0 comments on commit 1845b0a

Please sign in to comment.