Commit 4306a1e0 authored by Julien Muchembled's avatar Julien Muchembled

urlnormNormaliseUrl: make exception handling consistent

"raise urlnorm.InvalidUrl" was not catched because it was in an except clause.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42718 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4971f922
...@@ -3310,14 +3310,12 @@ def legacyNormalizeUrl(url, base_url=None): ...@@ -3310,14 +3310,12 @@ def legacyNormalizeUrl(url, base_url=None):
def urlnormNormaliseUrl(url, base_url=None): def urlnormNormaliseUrl(url, base_url=None):
"""The normalisation up is delegated to urlnorm library. """The normalisation up is delegated to urlnorm library.
""" """
try:
try: try:
url = urlnorm.norm(url) url = urlnorm.norm(url)
except UnicodeDecodeError: except UnicodeDecodeError:
try:
url = urlnorm.norm(url_unquote(url).decode('latin1')) url = urlnorm.norm(url_unquote(url).decode('latin1'))
except UnicodeDecodeError: except (AttributeError, UnicodeDecodeError, urlnorm.InvalidUrl):
raise urlnorm.InvalidUrl
except (AttributeError, urlnorm.InvalidUrl):
# This url is not valid, a better Exception will # This url is not valid, a better Exception will
# be raised # be raised
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment