py3: Fix unicode spaces being replaced by normal space in the edit metadata dialog

Fixes #1863525 [IDEOGRAPHIC SPACE (U+3000) is not treated correctly](https://bugs.launchpad.net/calibre/+bug/1863525)
This commit is contained in:
Kovid Goyal 2020-02-17 10:22:44 +05:30
parent 351781e869
commit 936e8b6382
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -30,6 +30,7 @@ from calibre.utils.date import (
local_tz, qt_to_dt, as_local_time, UNDEFINED_DATE, is_date_undefined, local_tz, qt_to_dt, as_local_time, UNDEFINED_DATE, is_date_undefined,
utcfromtimestamp, parse_only_date, internal_iso_format_string) utcfromtimestamp, parse_only_date, internal_iso_format_string)
from calibre import strftime from calibre import strftime
from calibre.constants import ispy3
from calibre.ebooks import BOOK_EXTENSIONS from calibre.ebooks import BOOK_EXTENSIONS
from calibre.customize.ui import run_plugins_on_import from calibre.customize.ui import run_plugins_on_import
from calibre.gui2.comments_editor import Editor from calibre.gui2.comments_editor import Editor
@ -52,7 +53,7 @@ def save_dialog(parent, title, msg, det_msg=''):
def clean_text(x): def clean_text(x):
return re.sub(r'\s', ' ', x.strip()) return re.sub(r'\s', ' ', x.strip(), flags=re.ASCII if ispy3 else 0)
''' '''
@ -221,7 +222,6 @@ class TitleEdit(EnLineEdit, ToMetadataMixin):
@property @property
def current_val(self): def current_val(self):
title = clean_text(unicode_type(self.text())) title = clean_text(unicode_type(self.text()))
if not title: if not title:
title = self.get_default() title = self.get_default()