limit link schemes in in messages in e-mail push notifications#19741
limit link schemes in in messages in e-mail push notifications#19741RamReso wants to merge 2 commits into
Conversation
| 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.
Ideally: add a test case (or otherwise) demonstrate that
safe_markupmakes use of the this schema allowlist.
A test would be good. Have you at least tested this manually? Please provide some instructions
| @@ -112,7 +112,7 @@ | |||
| "img": ["src"], | |||
| } | |||
| # When bleach release a version with this option, we can specify schemes | |||
There was a problem hiding this comment.
Comment is no longer relevant since we're using a version of bleach that supports this
| # When bleach release a version with this option, we can specify schemes |
| 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.
Do we even need to define this?
The list of
ALLOWED_PROTOCOLSnow defaults to http, https
and mailto
And I can see it in their code: https://github.com/mozilla/bleach/blob/913ab75992b845e2c9c060c41f24d46921db4693/bleach/sanitizer.py#L37-L38
| 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.
To make it more clear, the minimum version of bleach needed to use the protocols argument is 1.5 (https://github.com/mozilla/bleach/releases/tag/v1.5)
We're now using bleach>=3.2.0 as our minimum so we're good on this front ✅
Lines 75 to 76 in 8eb220a
| # When bleach release a version with this option, we can specify schemes | ||
| # ALLOWED_SCHEMES = ["http", "https", "ftp", "mailto"] | ||
| ALLOWED_SCHEMES = ["http", "https", "mailto"] |
There was a problem hiding this comment.
Depending on the answer to #19741 (comment) we can at-least use this PR remove this entire comment (and the commented out usage).
Resolves #2860. This pull request limits the allowed link schemes from messages contained in e-mail push notifications.
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.