From 261502e49ca29aed2855980d9c3673edd712aeb4 Mon Sep 17 00:00:00 2001 From: UlrichB22 <97119703+UlrichB22@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:45:23 +0200 Subject: [PATCH] Reject preview of empty items --- src/moin/items/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/moin/items/__init__.py b/src/moin/items/__init__.py index cea05c789..7d46ef045 100644 --- a/src/moin/items/__init__.py +++ b/src/moin/items/__init__.py @@ -1337,8 +1337,11 @@ def do_modify(self): old_item = Item.create(self.fqname.fullname, rev_id=CURRENT, contenttype=self.contenttype) old_text = old_item.content.data old_text = Text(old_item.contenttype, item=old_item).data_storage_to_internal(old_text) - preview_diffs = [(d[0], Markup(d[1]), d[2], Markup(d[3])) for d in html_diff(old_text, data)] - preview_rendered = item.content._render_data(preview=data) + if data: + preview_diffs = [(d[0], Markup(d[1]), d[2], Markup(d[3])) for d in html_diff(old_text, data)] + preview_rendered = item.content._render_data(preview=data) + else: # TODO: make preview button inactive for empty items, see #1539 + flash(_("No preview available for empty items."), 'error') close_file(old_item.rev.data) else: # user clicked OK/Save button, check for conflicts,