You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there is an unclosed parenthesis in URL and we use url validator, it causes an infinite loop. What's more interesting is that it only happens when the unclosed parenthesis is followed by many characters (check test case number 3 and 4).
from colander import MappingSchema, SchemaNode, Str, url
class MySchema(MappingSchema):
url = SchemaNode(Str(encoding='utf-8'), validator=url)
print MySchema().deserialize({"url": "http://www.mysite.com/tttttttttttttttttttttt.jpg"}) # it works
print MySchema().deserialize({"url": "http://www.mysite.com/(tttttttttttttttttttttt).jpg"}) # it works
print MySchema().deserialize({"url": "http://www.mysite.com/(ttttttttttt.jpg"}) # it works
print MySchema().deserialize({"url": "http://www.mysite.com/(tttttttttttttttttttttt.jpg"}) # infinite loop
In addition, if you check it in an online regex checker (https://regex101.com/) it also fails. Try this regex, it's used for URL validation in colander. It's taken from colander.__init__.py:438, I only escaped two slashes here.
When there is an unclosed parenthesis in URL and we use url validator, it causes an infinite loop. What's more interesting is that it only happens when the unclosed parenthesis is followed by many characters (check test case number 3 and 4).
In addition, if you check it in an online regex checker (https://regex101.com/) it also fails. Try this regex, it's used for URL validation in colander. It's taken from colander.__init__.py:438, I only escaped two slashes here.
Use this URL: http://www.mysite.com/(tttttttttttttttttttttt.jpg and you'll get catastrophic backtracking. You can use debugger on that site to check which group falls in infinite loop.
The text was updated successfully, but these errors were encountered: