diff options
author | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-11 17:30:09 +0200 |
---|---|---|
committer | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-11 17:30:09 +0200 |
commit | 87548030cbeaeff301afd297e052ceb5bc438ca7 (patch) | |
tree | bd0fb23789a25b2b53fdd3a6db516e6e3ee63427 /mediagoblin/tools/validator.py | |
parent | 5430bc2cdd513df8b27856b0d47999b3deac3622 (diff) | |
download | mediagoblin-87548030cbeaeff301afd297e052ceb5bc438ca7.tar.lz mediagoblin-87548030cbeaeff301afd297e052ceb5bc438ca7.tar.xz mediagoblin-87548030cbeaeff301afd297e052ceb5bc438ca7.zip |
fix auth error and simplify url and email checks
Diffstat (limited to 'mediagoblin/tools/validator.py')
-rw-r--r-- | mediagoblin/tools/validator.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/mediagoblin/tools/validator.py b/mediagoblin/tools/validator.py index 03598f9c..e8031a44 100644 --- a/mediagoblin/tools/validator.py +++ b/mediagoblin/tools/validator.py @@ -14,21 +14,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from wtforms.validators import Email, URL +import six def validate_email(email): - """ - Validates an email - - Returns True if valid and False if invalid """ + Validates an email - email_re = Email().regex - result = email_re.match(email) - if result is None: - return False - else: - return result.string + Returns True if valid and False if invalid + """ + return '@' in email def validate_url(url): """ @@ -36,11 +30,9 @@ def validate_url(url): Returns True if valid and False if invalid """ - - url_re = URL().regex - result = url_re.match(url) - if result is None: + try: + six.moves.urlparse(url) + return True + except Except as e: return False - else: - return result.string |