2024-10-15 14:40:20,591::INFO::[notifier:157] Sending notification: Error - SQL Command Failed, see log (type=error, job_cat=None)
2024-10-15 14:40:20,591::ERROR::[database:154] SQL Command Failed, see log
2024-10-15 14:40:20,591::INFO::[database:155] SQL: INSERT INTO history (completed, name, nzb_name, category, pp, script, report,
url, status, nzo_id, storage, path, script_log, script_line, download_time, postproc_time, stage_log,
downloaded, fail_message, url_info, bytes, duplicate_key, md5sum, password)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2024-10-15 14:40:20,592::INFO::[database:156] Arguments: (1729003220, 'test', 'test.nzb', '*', 'D', 'Default', '', None, 'Completed', 'SABnzbd_nzo_mfg7581n', '/mnt/test.1/weird.characters.\udc96.txt', '/var/lib/sabnzbd/Downloads/incomplete/test.1', '', '', 0, 0, 'Servers:::server=288 B\r\nDownload:::Downloaded in 0 seconds at an average of 918 B/s<br/>Age: 2m\r\nSource:::test.nzb\r\nRepair:::[test] No par2 sets;[test] Trying RAR-based verification;[test] RAR files verified successfully\r\nUnpack:::[test] Direct Unpack - Unpacked 1 files/folders in 0 seconds', 230, '', '', 230, None, '4da44f19d4f2410a09356163191507b3', None)
2024-10-15 14:40:20,592::INFO::[database:157] Traceback:
Traceback (most recent call last):
File "/usr/lib/sabnzbd/sabnzbd/database.py", line 128, in execute
self.cursor.execute(command, args)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc96' in position 50: surrogates not allowed
2024-10-15 14:40:20,592::INFO::[database:308] Added job test to history
2024-10-15 14:40:20,524::INFO::[postproc:482] Unpacked files ['/mnt/_UNPACK_test.1/weird.characters.\ufffe\ue096.txt']
A possible solution would be to extend the functions responsible for sanitizing filenames/foldernames to strip such characters.
touch weird.characters.$'\226'.txt
rar a test weird.characters.$'\226'.txt
nyuu [...] -o test.nzb test.rar
SABnzbd version
4.3.3
Operating system
Arch Linux
Using Docker image
None
Description
If the
pathreturned byone_file_or_folder()contains unicode surrogate code points, adding the history entry will fail on download completion withSQL Command Failed. It looks like utf-8 encoding is performed on the string query parameters, which fails due to the special character:sabnzbd/sabnzbd/postproc.py
Line 669 in fb0ef21
(
workdir_completeis later used aspathin the SQL query)(line numbers are off due to me adding debug statements everywhere)
Here, the filename contains the special character
\udc96(as reported byos.listdir()). Interestingly, the filename reported by the unpacker contains\ufffe\ue096instead:A possible solution would be to extend the functions responsible for sanitizing filenames/foldernames to strip such characters.
Reproduction Steps:
$'\226'in its name