aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-11-01 00:00:19 +0000
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-11-02 08:35:24 +0000
commit070aeddf76fd685c52d527098425fe34886326ea (patch)
treedb7bbd61d1676206cc0bff4f77e35647fc9182da /epan/proto.c
parente63857aa4e3830a9048ab785906f005405f68975 (diff)
Lift restriction on upper case protocol display filter names
Unlike other header fields in filter expressions protocol names cannot contain upper-case letters. Remove that restriction. This should make start-up slightly faster as it remove an extra loop for each protocol filter name. This was added in 9ead15a6eb16be93559d71b4083948338ab9d26e but I don't see a reason to have different rules for protocols and fields, it seems the README.developer was just being vague and conflating PROTOABBREV with PROTOFILTERNAME. The recommendation for lower case is a style recommendation, and it's a good one, but it should be applied uniformly. As long as we are not enforcing this for all field filter values there is no point in enforcing it just for protocol names and actually it is detrimental, e.g: hi2operations HI2Operations.IRIsContent HI2Operations.UUS1_Content_element HI2Operations.iRIContent HI2Operations.iRISequence HI2Operations.IRIContent HI2Operations.iRI_Begin_record_element HI2Operations.iRI_End_record_element HI2Operations.iRI_Continue_record_element HI2Operations.iRI_Report_record_element (...) It's weird and unexpected to have this difference and there is no technical reason to require it. What we should probably do is not include the protocol name in the FIELDFILTERNAME and have the registration mechanism append it to the PROTOFILTERNAME. Also disallow leading '-' everywhere in filter names, not just protocol filter names. It's a universal requirement.
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 6f9efbc8ab..5b13e601e9 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -7363,21 +7363,9 @@ proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start,
static void
check_valid_filter_name_or_fail(const char *filter_name)
{
- gboolean found_invalid = proto_check_field_name(filter_name);
-
- /* Additionally forbid upper case characters. */
- if (!found_invalid) {
- for (guint i = 0; filter_name[i]; i++) {
- if (g_ascii_isupper(filter_name[i])) {
- found_invalid = TRUE;
- break;
- }
- }
- }
-
- if (found_invalid) {
+ if (proto_check_field_name(filter_name) != '\0') {
ws_error("Protocol filter name \"%s\" has one or more invalid characters."
- " Allowed are lower characters, digits, '-', '_' and non-repeating '.'."
+ " Allowed are letters, digits, '-', '_' and non-repeating '.'."
" This might be caused by an inappropriate plugin or a development error.", filter_name);
}
@@ -7386,12 +7374,6 @@ check_valid_filter_name_or_fail(const char *filter_name)
ws_error("Protocol filter name \"%s\" is invalid because it is a reserved keyword."
" This might be caused by an inappropriate plugin or a development error.", filter_name);
}
-
- /* First character cannot be '-'. */
- if (filter_name[0] == '-') {
- ws_error("Protocol filter name \"%s\" cannot begin with '-'."
- " This might be caused by an inappropriate plugin or a development error.", filter_name);
- }
}
int
@@ -13168,6 +13150,10 @@ proto_check_field_name(const gchar *field_name)
const char *p = field_name;
guchar c = '.', lastc;
+ /* First character cannot be '-'. */
+ if (field_name[0] == '-')
+ return '-';
+
do {
lastc = c;
c = *(p++);