Reject field name with : { or }

More than {{ is acceptable to start a tag, which means that `{{{Foo}}` won't be interpreted as "the content of `Foo`"
and should be rejected. For the sake of clarity and parsing, I suspect that those symbol should be rejected elsewhere
too.

Similary `{{Foo}}}` won't be interpreted as "Show the content of field `Foo}`" even if this field exists, so it's better
to reject `}`. It's clearly necessary to reject "}}" inside the field name, rejecting "}" seems easier to explain and
avoid future unexpected problem if the templates change.

The ":" are used to separate filters, and rejecting it in field name would ensure that there is no ambiguity.
This commit is contained in:
Arthur Milchior 2020-12-27 10:07:56 +01:00
parent af6cb6612e
commit 89ffbe0fbb
2 changed files with 6 additions and 1 deletions

View File

@ -12,4 +12,5 @@ fields-reverse-text-direction-rtl = Reverse text direction (RTL)
fields-size = Size:
fields-sort-by-this-field-in-the = Sort by this field in the browser
fields-that-field-name-is-already-used = That field name is already used.
fields-name-first-letter-not-valid = The field name should not start with #, ^ or /.
fields-name-first-letter-not-valid = The field name should not start with #, ^ or /.
fields-name-invalid-letter = The field name should not contain :, ", { or }.

View File

@ -88,6 +88,10 @@ class FieldDialog(QDialog):
if txt[0] in "#^/":
showWarning(tr(TR.FIELDS_NAME_FIRST_LETTER_NOT_VALID))
return
for letter in """:{"}""":
if letter in txt:
showWarning(tr(TR.FIELDS_NAME_INVALID_LETTER))
return
for f in self.model["flds"]:
if ignoreOrd is not None and f["ord"] == ignoreOrd:
continue