diff --git a/src/calibre/db/notes/exim.py b/src/calibre/db/notes/exim.py index b2b3bd542c..fb149f9a4e 100644 --- a/src/calibre/db/notes/exim.py +++ b/src/calibre/db/notes/exim.py @@ -58,8 +58,8 @@ def import_note(shtml: str | bytes, basedir: str, add_resource) -> dict: img.set('data-pre-import-src', src) if src.startswith('data:'): d = src.split(':', 1)[-1] - menc, payload = d.partition(',') - mt, enc = menc.partition(';') + menc, payload = d.partition(',')[::2] + mt, enc = menc.partition(';')[::2] if enc != 'base64': continue try: diff --git a/src/calibre/db/tests/notes.py b/src/calibre/db/tests/notes.py index cc05925e02..4e13c95c70 100644 --- a/src/calibre/db/tests/notes.py +++ b/src/calibre/db/tests/notes.py @@ -140,6 +140,17 @@ def test_cache_api(self: 'NotesTest'): from html5_parser import parse root = parse(exported) self.ae(root.xpath('//img/@data-filename'), ['r 1.png', 'r 2.png']) + cache.set_notes_for('authors', author_id, '') + with open(os.path.join(tdir, 'e.html'), 'wb') as f: + f.write(exported.encode('utf-8')) + cache.import_note('authors', author_id, f.name) + note_id = cache.import_note('authors', author_id, f.name) + self.assertGreater(note_id, 0) + self.assertIn('
test simple exim