macOS: Fix opening book folder or PDF files for books with square brackets in the title not working. Fixes #2105884 [(MacOS) Can't open PDFs or "open book folder" if Title contains "[" or "]"](https://bugs.launchpad.net/calibre/+bug/2105884)

I have patched the Qt bundled with calibre with the upstream fix for
https://bugreports.qt.io/browse/QTBUG-134073
This commit is contained in:
Kovid Goyal 2025-04-02 11:14:19 +05:30
parent e8553dcfa0
commit 53faf44a03
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -14,7 +14,7 @@ from threading import Thread
from qt.core import QDialog, QDialogButtonBox, QImageReader, QLabel, QMimeData, QPixmap, QProgressBar, Qt, QTimer, QUrl, QVBoxLayout from qt.core import QDialog, QDialogButtonBox, QImageReader, QLabel, QMimeData, QPixmap, QProgressBar, Qt, QTimer, QUrl, QVBoxLayout
from calibre import as_unicode, browser, prints from calibre import as_unicode, browser, prints
from calibre.constants import DEBUG, ismacos, iswindows from calibre.constants import DEBUG, iswindows
from calibre.gui2 import error_dialog from calibre.gui2 import error_dialog
from calibre.ptempfile import PersistentTemporaryFile from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils.filenames import make_long_path_useable from calibre.utils.filenames import make_long_path_useable
@ -390,9 +390,4 @@ def has_firefox_ext(md, exts):
def set_urls_from_local_file_paths(md: QMimeData, *paths: str) -> QMimeData: def set_urls_from_local_file_paths(md: QMimeData, *paths: str) -> QMimeData:
md.setUrls(list(map(QUrl.fromLocalFile, paths))) md.setUrls(list(map(QUrl.fromLocalFile, paths)))
if ismacos:
# see https://bugreports.qt.io/browse/QTBUG-134073
raw = bytes(md.data('text/uri-list'))
raw = raw.replace(b'[', b'%5B').replace(b']', b'%5D')
md.setData('text/uri-list', raw)
return md return md