Modify ↓
#8284 closed defect (fixed)
verify_custom_field pattern for name is out of date with respect to Trac
Reported by: | pipern | Owned by: | osimons |
---|---|---|---|
Priority: | normal | Component: | CustomFieldAdminPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
See trac:#2431 for the pattern they use. At time of writing: http://trac.edgewall.org/browser/trunk/trac/ticket/api.py?rev=10341#L340
Here is a patch:
-
plugins/open/customfieldadminplugin/customfieldadmin/api.py
a b class CustomFields(Component): 55 55 # Use lowercase custom fieldnames only 56 56 customfield['name'] = customfield['name'].lower() 57 57 # Only alphanumeric characters (and [-_]) allowed for custom fieldname 58 if re.search('^[a-z0-9-_]+$', customfield['name']) == None: 59 raise TracError("Only alphanumeric characters allowed for custom field name (a-z or 0-9 or -_).") 58 # expression should match ticket/api.py pattern for "Invalid name". 59 if re.search('^[a-zA-Z][a-zA-Z0-9_]+$', customfield['name']) == None: 60 raise TracError("Only alphanumeric characters allowed for custom field name (a-z or 0-9 or _).") 60 61 # Check that it is a valid field type 61 62 if not customfield['type'] in ['text', 'checkbox', 'select', 'radio', 'textarea']: 62 63 raise TracError("%s is not a valid field type" % customfield['type'])
Trac seems to allow mixed case, but this plugin doesn't. I've not changed that, and this plugin still forces to lower case.
Attachments (0)
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Ah. One more thing. only 'a-z'
is allowed as first character. I'll add that too.
comment:3 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [9628]) CustomFieldAdminPlugin: Updated the 'allowed-names' regexp pattern to match the naming pattern allowed by Trac when it reads the config. Changes:
- First character must be
'a-z'
- Dash
'-'
not allowed in field name
comment:4 Changed 14 years ago by
(In [9629]) CustomFieldAdminPlugin: Follow-up to [9628], improve the error message and make it report what the regexp actually checks.
See #8284
Note: See
TracTickets for help on using
tickets.
The underlying option parser is case-insensitive, so
MYFIELD = text
andmyfield = text
is identical when parsed. That is why I just keep all use in the plugin lower-case and also do a.lower()
on the name before the regexp. So Trac allows same case just because it does not matter. However, Trac only reads so it does not care. Seeing the plugin both reads, evaluates, compares and writes, doing a same-case standardization just makes sense for me.The only real difference is in fact that the plugin allows use of the dash (
'-'
) character in names whereas Trac won't allow it. Looking back at current 0.11-stable it isn't allowed there either. I should change that.