Skip to content

Commit

Permalink
Merge pull request #1239 from specters312/FixTxTFileDomainUpload
Browse files Browse the repository at this point in the history
Fix Txt File Var Declaration
  • Loading branch information
yogeshojha authored May 9, 2024
2 parents ed3e61f + 6f025cd commit 6267fd9
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 6267fd9

Please sign in to comment.