Modify ↓
#13220 closed enhancement (fixed)
Prevent reserved field name when adding a field via form
Reported by: | Jun Omae | Owned by: | jomae |
---|---|---|---|
Priority: | normal | Component: | CustomFieldAdminPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
Trac ignores reserved names in custom fields.
2017-06-22 19:53:07,790 (7fe956e49700) WARNING: Field name "group" is a reserved name (ignoring)
We could validate a field name is not listed in TicketSystem.reserved_field_names
. The reserved_field_names
property is available since Trac-0.11.3 (introduced in trac:r7769).
At trac:source:/tags/trac-1.0.15/trac/ticket/api.py@:352-354,365-367#L347]:
352 if field['name'] in self.reserved_field_names: 353 self.log.warning('Field name "%s" is a reserved name ' 354 '(ignoring)', field['name']) 355 continue ... 365 reserved_field_names = ['report', 'order', 'desc', 'group', 'groupdesc', 366 'col', 'row', 'format', 'max', 'page', 'verbose', 367 'comment', 'or']
-
customfieldadminplugin/0.11/customfieldadmin/api.py
diff --git a/customfieldadminplugin/0.11/customfieldadmin/api.py b/customfieldadminplugin/0.11/customfieldadmin/api.py index b8349f765..85f8012e3 100644
a b class CustomFields(Component): 100 100 raise TracError(_("Only alphanumeric characters allowed for " \ 101 101 "custom field name ('a-z' or '0-9' or '_'), " \ 102 102 "with 'a-z' as first character.")) 103 tktsys = TicketSystem(self.env) 104 if cfield['name'] in tktsys.reserved_field_names: 105 raise TracError(_("Field name is reserved")) 103 106 # Name must begin with a character - anything else not supported by Trac 104 107 if not cfield['name'][0].isalpha(): 105 108 raise TracError( … … class CustomFields(Component): 113 116 # (if modify it should already be deleted) 114 117 if create and self.config.get('ticket-custom', cfield['name']): 115 118 raise TracError(_("Can not create as field already exists.")) 116 if create and [f for f in TicketSystem(self.env).fields119 if create and [f for f in tktsys.fields 117 120 if f['name'] == cfield['name']]: 118 121 raise TracError(_("Can't create a custom field with the " 119 122 "same name as a built-in field."))
Attachments (0)
Change History (3)
comment:1 Changed 7 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 Changed 7 years ago by
Owner: | changed from osimons to jomae |
---|
I'll also incorporate into the branch I'm preparing for trac:#11469.
Note: See
TracTickets for help on using
tickets.
In 16676: