From 6f025cd7df64ab8835b6f2ac80b67433e70dcb81 Mon Sep 17 00:00:00 2001 From: --Lol-- <11202351+specters312@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:16:21 -0600 Subject: [PATCH] Fix Txt File Var Declaration Worked on fixing the txt file upload so I can just get a bunch of domains and yeet it into this. --- web/targetApp/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/targetApp/views.py b/web/targetApp/views.py index c67cbee41..e49149785 100644 --- a/web/targetApp/views.py +++ b/web/targetApp/views.py @@ -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: @@ -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,