From 4ebba02b6b209cbf45344c3045b363e194fe634a Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Sat, 18 Mar 2023 11:42:51 +0100 Subject: [PATCH] Fix crash when invalid note link Fixes #012854 --- gramps/gen/proxy/referencedbyselection.py | 2 +- gramps/gui/widgets/styledtexteditor.py | 4 ++-- gramps/plugins/lib/libhtmlbackend.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gramps/gen/proxy/referencedbyselection.py b/gramps/gen/proxy/referencedbyselection.py index 4b678ccb3..5d95f286c 100644 --- a/gramps/gen/proxy/referencedbyselection.py +++ b/gramps/gen/proxy/referencedbyselection.py @@ -346,7 +346,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase): for tag in note.text.get_tags(): if tag.name == 'Link': if tag.value.startswith("gramps://"): - obj_class, prop, value = tag.value[9:].split("/") + obj_class, prop, value = tag.value[9:].split("/", 2) if obj_class == "Media": # bug6493 obj_class = "Media" if prop == "handle": diff --git a/gramps/gui/widgets/styledtexteditor.py b/gramps/gui/widgets/styledtexteditor.py index 59e3bedea..e5f53d490 100644 --- a/gramps/gui/widgets/styledtexteditor.py +++ b/gramps/gui/widgets/styledtexteditor.py @@ -396,7 +396,7 @@ class StyledTextEditor(Gtk.TextView): simple_access = SimpleAccess(win_obj.dbstate.db) url = link_tag.data if url.startswith("gramps://"): - obj_class, prop, value = url[9:].split("/") + obj_class, prop, value = url[9:].split("/", 2) display = simple_access.display(obj_class, prop, value) or url return display + ((_("\nCommand-Click to follow link") if mac() else _("\nCtrl-Click to follow link")) @@ -809,7 +809,7 @@ class StyledTextEditor(Gtk.TextView): win_obj = find_parent_with_attr(self, attr="dbstate") if win_obj: # Edit the object: - obj_class, prop, value = url[9:].split("/") + obj_class, prop, value = url[9:].split("/", 2) from ..editors import EditObject EditObject(win_obj.dbstate, win_obj.uistate, diff --git a/gramps/plugins/lib/libhtmlbackend.py b/gramps/plugins/lib/libhtmlbackend.py index f237693f6..db440d071 100644 --- a/gramps/plugins/lib/libhtmlbackend.py +++ b/gramps/plugins/lib/libhtmlbackend.py @@ -300,7 +300,7 @@ class HtmlBackend(DocBackend): """ if value.startswith("gramps://"): if self.build_link: - obj_class, prop, handle = value[9:].split("/", 3) + obj_class, prop, handle = value[9:].split("/", 2) if prop in ["handle", "gramps_id"]: value = self.build_link(prop, handle, obj_class) if not value: