Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Txt File Var Declaration #1239

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions web/targetApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def add_target(request, slug):
'Files uploaded are not .txt or .csv files.')
return http.HttpResponseRedirect(reverse('add_target', kwargs={'slug': slug}))

#Specters Fix
if txt_file:
is_txt = txt_file.content_type == 'text/plain' or txt_file.name.split('.')[-1] == 'txt'
if not is_txt:
Expand All @@ -167,10 +168,11 @@ def add_target(request, slug):
io_string = io.StringIO(txt_content)
for target in io_string:
target_domain = target.rstrip("\n").rstrip("\r")
domain = None # Move the domain variable declaration here
domain_query = Domain.objects.filter(name=target_domain)
if not domain_query.exists():
if not validators.domain(domain):
messages.add_message(request, messages.ERROR, f'Domain {domain} is not a valid domain name. Skipping.')
if not validators.domain(target_domain): # Change 'domain' to 'target_domain'
messages.add_message(request, messages.ERROR, f'Domain {target_domain} is not a valid domain name. Skipping.')
continue
Domain.objects.create(
name=target_domain,
Expand Down