feat: Remove scripts from render
This commit is contained in:
parent
d4d987944a
commit
3ba951fa42
@ -8,4 +8,5 @@ email-validator
|
|||||||
py3dns
|
py3dns
|
||||||
passlib
|
passlib
|
||||||
argon2-cffi
|
argon2-cffi
|
||||||
mysql-connector-python
|
mysql-connector-python
|
||||||
|
beautifulsoup4
|
@ -1,8 +1,17 @@
|
|||||||
from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory
|
from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def render(data):
|
def render(data):
|
||||||
if data == "":
|
if data == "":
|
||||||
return "No data found for this domain"
|
return "No data found for this domain"
|
||||||
|
|
||||||
return render_template_string(data)
|
try:
|
||||||
|
soup = BeautifulSoup(data, 'html.parser')
|
||||||
|
for script in soup.find_all('script'):
|
||||||
|
script.extract()
|
||||||
|
modified_data = str(soup)
|
||||||
|
return render_template_string(modified_data)
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return "<h1>Invalid HTML</h1><br>" + str(e)
|
Loading…
Reference in New Issue
Block a user