Improved whitespace removal

Testresults
This commit is contained in:
Ozzie Isaacs
2024-08-13 07:07:54 +02:00
parent 5f81084e66
commit 87b82424d5
14 changed files with 115 additions and 127 deletions
+2 -1
View File
@@ -39,6 +39,7 @@ from cps.file_helper import get_temp_dir
from cps.tasks.mail import TaskEmail
from cps import gdriveutils, helper
from cps.constants import SUPPORTED_CALIBRE_BINARIES
from cps.string_helper import strip_whitespaces
log = logger.create()
@@ -107,7 +108,7 @@ class TaskConvert(CalibreTask):
try:
EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title))
for email in self.ereader_mail.split(','):
email = email.strip()
email = strip_whitespaces(email)
worker_thread.add(self.user, TaskEmail(self.settings['subject'],
self.results["path"],
filename,
+3 -2
View File
@@ -34,6 +34,7 @@ from cps.services import gmail
from cps.embed_helper import do_calibre_export
from cps import logger, config
from cps import gdriveutils
from cps.string_helper import strip_whitespaces
import uuid
log = logger.create()
@@ -127,9 +128,9 @@ class TaskEmail(CalibreTask):
try:
# Parse out the address from the From line, and then the domain from that
from_email = parseaddr(self.settings["mail_from"])[1]
msgid_domain = from_email.partition('@')[2].strip()
msgid_domain = strip_whitespaces(from_email.partition('@')[2])
# This can sometimes sneak through parseaddr if the input is malformed
msgid_domain = msgid_domain.rstrip('>').strip()
msgid_domain = strip_whitespaces(msgid_domain.rstrip('>'))
except Exception:
msgid_domain = ''
return msgid_domain or 'calibre-web.com'