Commit: 7c9de23c5c57b4e8083cd738357ebb85beca3572
Parent: f50882c5ed33a741b708aedecdd2df38e8edbb31
Author: Ren Tatsumoto
Date: Tue, 23 Mar 2021 14:31:34 +0300
prevent crash if sentence is empty
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -343,6 +343,12 @@ local function update_sentence(new_data, stored_data)
-- adds support for TSCs
-- https://tatsumoto-ren.github.io/blog/discussing-various-card-templates.html#targeted-sentence-cards-or-mpvacious-cards
-- if the target word was marked by yomichan, this function makes sure that the highlighting doesn't get erased.
+
+ if is_empty(stored_data[config.sentence_field]) then
+ -- sentence field is empty. can't continue.
+ return new_data
+ end
+
local _, opentag, target, closetag, _ = stored_data[config.sentence_field]:match('^(.-)(<[^>]+>)(.-)(</[^>]+>)(.-)$')
if target then
local prefix, _, suffix = new_data[config.sentence_field]:match(table.concat { '^(.-)(', target, ')(.-)$' })