From: Oleg Broytman Date: Sun, 12 Nov 2023 18:56:15 +0000 (+0300) Subject: Fix(robots): Process redirect with non-encoded URL X-Git-Tag: 5.0.0~41 X-Git-Url: https://git.phdru.name/?p=bookmarks_db.git;a=commitdiff_plain;h=48440e20170112c8a036b0c66c1cbe067ed1d87e Fix(robots): Process redirect with non-encoded URL --- diff --git a/Robots/bkmk_robot_base.py b/Robots/bkmk_robot_base.py index b5cac69..85c704a 100644 --- a/Robots/bkmk_robot_base.py +++ b/Robots/bkmk_robot_base.py @@ -274,8 +274,15 @@ class robot_base(Robot): return 1 def set_redirect(self, bookmark, errcode, newurl): - bookmark.moved = "(%s) to %s" % (reloc_dict[errcode], newurl) - self.log(' Moved: %s' % bookmark.moved) + bookmark.moved = moved = "(%s) to %s" % (reloc_dict[errcode], newurl) + try: + moved.encode('ascii') + except UnicodeEncodeError: + try: + moved = moved.encode(bookmark.charset) + except (LookupError, TypeError, UnicodeEncodeError): + moved = moved.encode('utf-8') + self.log(' Moved: %s' % moved) def finish_check_url(self, bookmark): start = self.start