From 5ab71b84e0dd2681fb3ea44a64e8491bc4c18446 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 8 Nov 2023 23:25:01 +1100 Subject: [PATCH] fix: Try new sanitization --- requirements.txt | 2 +- sites/website.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index bcff7ca..e5cfa8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ passlib argon2-cffi mysql-connector-python beautifulsoup4 -lxml \ No newline at end of file +bleach \ No newline at end of file diff --git a/sites/website.py b/sites/website.py index ed3efc0..fda0f38 100644 --- a/sites/website.py +++ b/sites/website.py @@ -1,6 +1,6 @@ from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory from bs4 import BeautifulSoup -from lxml.html.clean import clean_html +import bleach def render(data): if data == "": @@ -10,9 +10,9 @@ def render(data): soup = BeautifulSoup(data, 'html.parser') for script in soup.find_all('script'): script.extract() - modified_data = str(soup) - - return render_template_string(clean_html(modified_data)) + + modified = str(soup) + return render_template_string(bleach.clean(modified)) except Exception as e: