From b7f27a2af0ea254c3e5f696e24c510fc65e9a4c6 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 23 Feb 2021 20:51:43 +0100 Subject: [PATCH] Don't save invalid keyword references to the index --- nw/core/index.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nw/core/index.py b/nw/core/index.py index 73d469c4..0932b34a 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -477,9 +477,17 @@ class NWIndex(): return False sTitle = "T%06d" % nTitle - if sTitle in self._refIndex[tHandle] and theBits[0] != nwKeyWords.TAG_KEY: - for aVal in theBits[1:]: - self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal]) + if sTitle not in self._refIndex[tHandle]: + return False + + if theBits[0] == nwKeyWords.TAG_KEY: + return False + + if theBits[0] not in nwKeyWords.VALID_KEYS: + return False + + for aVal in theBits[1:]: + self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal]) return True