Hi there,
I was just using the email validator and tried to whitelist domains.
However, when using a wrong domain the validator didn’t raise an error.
I had a look to the source code and was a bit confused by the logic:
if domain_part not in self.domain_allowlist and not self.validate_domain_part(
domain_part
):
raise ValidationError(self.message, code=self.code, params={"value": value})
Shouldn’t the two statements be connected via or
or am I misunderstanding the implementation?
At least it worked as I expected when I changed the and
to an or
.
If that’s the case, then this might be even be a security vulnerability if one can bypass a wrong domain simply by using a string that matches the standard regex.