From 1fb3b9ea2881a89eb8d1e0826161ccedc4a36b56 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Sep 2023 13:11:51 +0530 Subject: [PATCH] Sanitize filenames for notes resources --- src/calibre/db/notes/connect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/db/notes/connect.py b/src/calibre/db/notes/connect.py index 54604be1b3..2c6df281c5 100644 --- a/src/calibre/db/notes/connect.py +++ b/src/calibre/db/notes/connect.py @@ -11,6 +11,7 @@ from contextlib import suppress from itertools import count, repeat from typing import Optional +from calibre import sanitize_file_name from calibre.constants import iswindows from calibre.db import FTSQueryError from calibre.db.annotations import unicode_normalize @@ -322,6 +323,7 @@ class Notes: f = open(path, 'wb') with f: f.write(data) + name = sanitize_file_name(name) base_name, ext = os.path.splitext(name) c = 0 for (existing_name,) in conn.execute('SELECT name FROM notes_db.resources WHERE hash=?', (resource_hash,)):