Skip to content

Commit

Permalink
fix: disallow using the live service during extraction
Browse files Browse the repository at this point in the history
If we have to do this a third time, we probably want to wrap the
extractor in a utility function.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Sep 19, 2024
1 parent e760585 commit 73a6ce5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions warehouse/admin/views/prohibited_email_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyramid.httpexceptions import HTTPBadRequest, HTTPSeeOther
from pyramid.view import view_config
from sqlalchemy import exists, select
from tldextract import extract
from tldextract import TLDExtract

from warehouse.accounts.models import ProhibitedEmailDomain
from warehouse.authnz import Permissions
Expand Down Expand Up @@ -68,7 +68,8 @@ def add_prohibited_email_domain(request):
request.session.flash("Email domain is required.", queue="error")
raise HTTPSeeOther(request.route_path("admin.prohibited_email_domains.list"))
# validate that the domain is valid
registered_domain = extract(email_domain).registered_domain
extractor = TLDExtract(suffix_list_urls=()) # Updated during image build
registered_domain = extractor(email_domain).registered_domain
if not registered_domain:
request.session.flash(f"Invalid domain name '{email_domain}'", queue="error")
raise HTTPSeeOther(request.route_path("admin.prohibited_email_domains.list"))
Expand Down

0 comments on commit 73a6ce5

Please sign in to comment.