From 4049759aed1971bdf4b9180965aa636a4fbe2677 Mon Sep 17 00:00:00 2001 From: David Given <dg@cowlark.com> Date: Thu, 25 May 2023 00:17:03 +0200 Subject: [PATCH 1/3] Fix a nasty crashing bug if a document name started with digits but was not a valid number. --- src/lua/fileio.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua/fileio.lua b/src/lua/fileio.lua index 585e691c..f7709de1 100644 --- a/src/lua/fileio.lua +++ b/src/lua/fileio.lua @@ -496,9 +496,10 @@ local function loadfromstreamt(fp) -- This is setting a property value. local o = data for e in k:gmatch("[^.]+") do - if e:find('^[0-9]+') then + if e:find('^[0-9]+$') then e = tonumber(e) end + print(e) if not o[e] then if (o == data.documents) then o[e] = CreateDocument() From 76dd5129e422ab22af972a88e31514dd07822934 Mon Sep 17 00:00:00 2001 From: David Given <dg@cowlark.com> Date: Thu, 25 May 2023 00:18:17 +0200 Subject: [PATCH 2/3] Fix nasty crashing bug where a nil reference error would be thrown if a document name started with digits but wasn't a valid number. --- src/lua/fileio.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua/fileio.lua b/src/lua/fileio.lua index f7709de1..a4120928 100644 --- a/src/lua/fileio.lua +++ b/src/lua/fileio.lua @@ -499,7 +499,6 @@ local function loadfromstreamt(fp) if e:find('^[0-9]+$') then e = tonumber(e) end - print(e) if not o[e] then if (o == data.documents) then o[e] = CreateDocument() From 2ed7973b83fa732e1277aef2336ec203bf7c4c4d Mon Sep 17 00:00:00 2001 From: David Given <dg@cowlark.com> Date: Thu, 25 May 2023 00:21:52 +0200 Subject: [PATCH 3/3] Prevent the user from naming a subdocument as a number. --- src/lua/addons/docsetman.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lua/addons/docsetman.lua b/src/lua/addons/docsetman.lua index af5ad1c8..ffee0c1b 100644 --- a/src/lua/addons/docsetman.lua +++ b/src/lua/addons/docsetman.lua @@ -10,6 +10,11 @@ function Cmd.AddBlankDocument(name) end end + if name:find('^[0-9]+$') then + ModalMessage("Can't use this name", "Sorry! As a temporary bug workaround you can't use names which are numbers. This will be fixed shortly.") + return false + end + if DocumentSet.documents[name] then ModalMessage("Name in use", "Sorry! There's already a document with that name in this document set.") return false @@ -59,6 +64,11 @@ function Cmd.ManageDocumentsUI() return "confirm" end + if name:find('^[0-9]+$') then + ModalMessage("Can't use this name", "Sorry! As a temporary bug workaround you can't use names which are numbers. This will be fixed shortly.") + return "confirm" + end + if not DocumentSet:renameDocument(Document.name, name) then ModalMessage("Name in use", "Sorry! There's already a document with that name in this document set.") return "confirm"