diff --git a/epan/dfilter/scanner.l b/epan/dfilter/scanner.l index c8838a7219..cd63e08e7e 100644 --- a/epan/dfilter/scanner.l +++ b/epan/dfilter/scanner.l @@ -378,8 +378,12 @@ v6-cidr-prefix \/[[:digit:]]{1,3} return set_lval_str(TOKEN_UNPARSED, yytext); } -[[:xdigit:]]+:[[:xdigit:]:]* { +:?[[:xdigit:]]+:[[:xdigit:]:]* { /* Bytes. */ + if (yytext[0] == ':') { + /* Skip leading colon. */ + return set_lval_str(TOKEN_LITERAL, yytext + 1); + } return set_lval_str(TOKEN_UNPARSED, yytext); } @@ -392,8 +396,10 @@ v6-cidr-prefix \/[[:digit:]]{1,3} /* Identifier or literal or unparsed. */ if (yytext[0] == '.') return set_lval_str(TOKEN_IDENTIFIER, yytext); - if (yytext[0] == ':') - return set_lval_str(TOKEN_LITERAL, yytext); + if (yytext[0] == ':') { + /* Skip leading colon. */ + return set_lval_str(TOKEN_LITERAL, yytext + 1); + } return set_lval_str(TOKEN_UNPARSED, yytext); } diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c index eea3a7e9a8..305a84b43c 100644 --- a/epan/ftypes/ftypes.c +++ b/epan/ftypes/ftypes.c @@ -372,14 +372,7 @@ fvalue_from_literal(ftenum_t ftype, const char *s, gboolean allow_partial_value, fv = fvalue_new(ftype); if (fv->ftype->val_from_literal) { - if (*s == ':') { - ok = fv->ftype->val_from_literal(fv, s + 1, allow_partial_value, err_msg); - /* If not ok maybe leading colon is not special syntax but part of the value (e.g: IPv6), - * try again in that case. */ - } - if (!ok) { - ok = fv->ftype->val_from_literal(fv, s, allow_partial_value, err_msg); - } + ok = fv->ftype->val_from_literal(fv, s, allow_partial_value, err_msg); if (ok) { /* Success */ if (err_msg != NULL)