From 7c61b3509c186b1c75db857bc481f2edcb931509 Mon Sep 17 00:00:00 2001 From: Vitiko <59455966+vitiko98@users.noreply.github.com> Date: Fri, 2 Apr 2021 01:20:19 -0400 Subject: [PATCH] Fix bad identifier from frontend (#1361) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: vitiko98 --- frontend/src/Settings/Subtitles/index.tsx | 4 ++-- libs/subzero/modification/main.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/Settings/Subtitles/index.tsx b/frontend/src/Settings/Subtitles/index.tsx index 8328d7b4c..25dd2793c 100644 --- a/frontend/src/Settings/Subtitles/index.tsx +++ b/frontend/src/Settings/Subtitles/index.tsx @@ -225,8 +225,8 @@ const SettingsSubtitlesView: FunctionComponent = () => { Fix issues that happen when a subtitle gets converted from bitmap to diff --git a/libs/subzero/modification/main.py b/libs/subzero/modification/main.py index 69822b093..da41e2e7d 100644 --- a/libs/subzero/modification/main.py +++ b/libs/subzero/modification/main.py @@ -34,12 +34,12 @@ class SubtitleModifications(object): def load(self, fn=None, content=None, language=None, encoding="utf-8"): """ - + :param encoding: used for decoding the content when fn is given, not used in case content is given :param language: babelfish.Language language of the subtitle :param fn: filename - :param content: unicode - :return: + :param content: unicode + :return: """ if language: self.language = Language.rebuild(language, forced=False) @@ -64,11 +64,14 @@ class SubtitleModifications(object): @classmethod def parse_identifier(cls, identifier): # simple identifier - if identifier in registry.mods: + # ("=" conditional used to avoid unpack exceptions related to bad + # identifiers from old configs) + if identifier in registry.mods or "=" not in identifier: return identifier, {} # identifier with params; identifier(param=value) split_args = identifier[identifier.find("(")+1:-1].split(",") + args = dict((key, value) for key, value in [sub.split("=") for sub in split_args]) return identifier[:identifier.find("(")], args