-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Upgrade to Bleach 1.5, to limit link schemes to an allowlist #2860 #15793
Conversation
Sorry Mistakenly Closed |
sign off : SWAGAT SWAROOP PARIDA swagatswaroop@gmail.com This is my first open source contribution. If there are mistakes point out It will help me learn and grow with community. |
@@ -890,7 +890,7 @@ def safe_markup(raw_html: str) -> Markup: | |||
tags=ALLOWED_TAGS, | |||
attributes=ALLOWED_ATTRS, | |||
# bleach master has this, but it isn't released yet | |||
# protocols=ALLOWED_SCHEMES, | |||
protocols=ALLOWED_SCHEMES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using bleach == 6.0.0
in poetry.lock
but it looks like there is a breaking change where it needs to be a Set
now. As far as I can tell, we can't really support both versions before and after so would need to converge either way on our dependency versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's slightly alarming. I couldn't see a way in which this was obviously broken if you pass in a list, so not sure what's going on there.
$ python
Python 3.11.3 (main, May 24 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bleach
>>> bleach.__version__
'6.0.0'
>>> bleach.clean()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: clean() missing 1 required positional argument: 'text'
>>> bleach.clean('aaaaa')
'aaaaa'
>>> bleach.clean('<naughty>')
'<naughty>'
>>> bleach.clean('<naughty><a>')
'<naughty><a></a>'
>>> bleach.clean('<naughty><a href="foo">')
'<naughty><a href="foo"></a>'
>>> bleach.clean('<naughty><a href="foo">', tags=['a'])
'<naughty><a href="foo"></a>'
>>> bleach.clean('<naughty><a href="foo">', tags={'a'})
'<naughty><a href="foo"></a>'
>>> bleach.clean('<naughty><a href="foo">', tags={'a', 'naughty'})
'<naughty><a href="foo"></a></naughty>'
>>> bleach.clean('<naughty><a href="foo">', tags={'naughty'})
'<naughty><a href="foo"></naughty>'
>>> bleach.clean('<naughty><a href="foo">', tags=['naughty'])
'<naughty><a href="foo"></naughty>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though note that bleach is deprecated: mozilla/bleach#698
Pull Request Checklist
Uncommented the line of allowed protocols from safe_markup function and Allowed protocols as support is added in bleach library.
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)