From 9a8c85faf01baa5f499338543006040caf2d23e3 Mon Sep 17 00:00:00 2001 From: ggqinhome Date: Sat, 6 Jan 2024 13:05:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E4=B8=AD=E6=9C=89=E5=8D=95=E5=BC=95=E5=8F=B7=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=AF=BC=E5=87=BAhtml=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/exporter_html.py | 5 ++++- app/util/file.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/DataBase/exporter_html.py b/app/DataBase/exporter_html.py index f69414c..a12b29d 100644 --- a/app/DataBase/exporter_html.py +++ b/app/DataBase/exporter_html.py @@ -16,6 +16,7 @@ from app.util.compress_content import parser_reply, share_card, music_share, fil from app.util.emoji import get_emoji_url from app.util.image import get_image_path, get_image from app.util.music import get_music_path +from app.util.file import escape_single_quotes icon_files = { @@ -127,10 +128,12 @@ class HtmlExporter(ExporterBase): file_path = file_info.get('file_path') if file_path != "": file_path = './file/' + file_info.get('file_name') + file_path = escape_single_quotes(file_path) + file_name = escape_single_quotes(file_info.get('file_name')) doc.write( f'''{{ type:49, text: '{file_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp} ,is_chatroom:{is_chatroom},displayname:'{display_name}',icon_path: '{icon_path}' - ,sub_type:6,file_name: '{file_info.get('file_name')}',file_size: '{file_info.get('file_len')}' + ,sub_type:6,file_name: '{file_name}',file_size: '{file_info.get('file_len')}' ,app_name: '{file_info.get('app_name')}'}},''' ) diff --git a/app/util/file.py b/app/util/file.py index 8c8562f..42e4570 100644 --- a/app/util/file.py +++ b/app/util/file.py @@ -57,3 +57,6 @@ def get_file(bytes_extra, file_name, output_path=root_path) -> str: except: logger.error(traceback.format_exc()) return "" + +def escape_single_quotes(path_str:str) -> str: + return path_str.replace("'",r"\'") \ No newline at end of file