#3113 updated get_host to always validate the host characters. However, it also disallowed the empty string. This is a bit too strict, it should only validate the string if it's not empty, or if trusted_hosts is passed. And if it's not valid characters, it should return the empty string rather than failing.
This will match Django's behavior. I thought I had matched it before, as I referred to it when trying to figure out the right behavior here. But I ended up being more strict than it is. It treats empty strings and invalid characters as the empty string, rather than immediately returning an error.
Host is also nonexistant in HTTP/0.9 and optional in HTTP/1.0, so it might appear as the empty string in those cases and should be passed through.
To be clear: domain names still can't contain _ or a bunch of other characters. If you have a domain like that, you need to report it to/fix whatever's generating such a name. It just shouldn't fail loudly immediately, although it might produce invalid results or fail in other ways later.
#3113 updated
get_hostto always validate the host characters. However, it also disallowed the empty string. This is a bit too strict, it should only validate the string if it's not empty, or iftrusted_hostsis passed. And if it's not valid characters, it should return the empty string rather than failing.This will match Django's behavior. I thought I had matched it before, as I referred to it when trying to figure out the right behavior here. But I ended up being more strict than it is. It treats empty strings and invalid characters as the empty string, rather than immediately returning an error.
Hostis also nonexistant in HTTP/0.9 and optional in HTTP/1.0, so it might appear as the empty string in those cases and should be passed through.To be clear: domain names still can't contain
_or a bunch of other characters. If you have a domain like that, you need to report it to/fix whatever's generating such a name. It just shouldn't fail loudly immediately, although it might produce invalid results or fail in other ways later.