Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject preview of empty items to prevent traceback and http 500 #1553

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/moin/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down