Last active
August 29, 2015 13:56
-
-
Save simonklee/8842786 to your computer and use it in GitHub Desktop.
Domain whitelist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
class DomainWhitelist(object): | |
url_re = re.compile( | |
r'([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})', | |
re.IGNORECASE) | |
kogama_re = re.compile( | |
r'^(http[s]?://)?([a-z0-9-.]{2,8})?kogama.com(.br)?', | |
re.IGNORECASE) | |
def check(self, value): | |
for url in self.url_re.findall(value): | |
if not self.kogama_re.match(''.join(url)): | |
return False | |
return True |
Yes and no. You wont be able to write a comment with the username "simon.kogama" in it. However, that is not something we can solve, since domain and user names follow some of the same rules.
We do however not run these validations on usernames directly. Usernames are upon creation checked versus a much stricter regex which limits the possibilities. You can create a username like this xxx.com, but that is about it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We may have problems with usernames don't we? http://rubular.com/r/nFfQpESoPP