[issue2551196] Unset labelprop of a Multilink can lead to Python error when using context/history
Nagy Gabor <[email protected]> Thu, 17 Feb 2022 22:38:13 +0000
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
New submission from Nagy Gabor:
When the history renderer of the web interface wants to print the change of a multilink property in the form
"propname: + added_item",
e.g.
"documents: + mydocument.docx",
it will crash, if the label property of the newly linked item is None. And in this case we get a cryptic error message in the browser (see the attached file error.log), which requires some time to debug.
I agree that no item should have empty labelprop, but users can do strange things... (In my scenario, the user made a filename empty.)
The problem is in the history() method of _HTMLItem class in cgi/templating.py (lines 1241-1248):
# if we have a label property, try to use it
# TODO: test for node existence even when
# there's no labelprop!
try:
if labelprop is not None and \
labelprop != 'id':
label = linkcl.get(linkid, labelprop)
label = html_escape(label)
Here html_escape(None) leads to an unhandled exception. I've added an
if label is None:
label = "[empty]"
block before calling html_escape() as a workaround, and it is fixed my issue. I note that setting a default_value for the multilinked Class in schema.py does not help either, because the above code ignores default_value...
----------
components: Web interface
files: error.log
messages: 7453
nosy: ngaba
severity: normal
status: new
title: Unset labelprop of a Multilink can lead to Python error when using context/history
type: crash
versions: 2.1.0
_________________________________________________
Roundup tracker <[email protected]>
<https://issues.roundup-tracker.org/issue2551196>
_________________________________________________