forked from osmocom/wireshark
dfilter: Support more C escape sequences in string literals
Before: Filter: http.request.method == "\tHEAD" Constants: 00000 PUT_FVALUE "tHEAD" <FT_STRING> -> reg#1 (...) Filter: http.request.method == "\uHEAD" Constants: 00000 PUT_FVALUE "uHEAD" <FT_STRING> -> reg#1 (...) After: Filter: http.request.method == "\tHEAD" Constants: 00000 PUT_FVALUE "\x09HEAD" <FT_STRING> -> reg#1 (...) Filter: http.request.method == "\uHEAD" Constants: 00000 PUT_FVALUE "uHEAD" <FT_STRING> -> reg#1 (...)
This commit is contained in:
parent
82ced8965c
commit
9ca27643fa
|
@ -116,6 +116,9 @@ The following features are new (or have been significantly updated) since versio
|
|||
** Use the syntax "a ~= b" or "a any_ne b" to recover the previous (inconsistent with ==) logic for not equal.
|
||||
** Adds support for the syntax "a not in b" as a synonym for "not a in b".
|
||||
** Set elements must be separated using a comma, e.g: {1, 2, "foo"}. Using only whitespace as separator was deprecated in 3.6 and is now a syntax error.
|
||||
** Adds support for some additional character escape sequences in double quoted strings. Besides octal and hex byte specification the following C escape
|
||||
sequences are now supported with the same meaning: \a, \b, \f, \n, \r, \t, \v. Previously they were only supported with character constants. Note that
|
||||
unrecognized escape sequences are treated as a literal character. This has not changed from previous versions.
|
||||
|
||||
* Corrected calculation of mean jitter in RTP Stream Analysis dialog and IAX2 Stram Analysis dialog
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ df_lval_t *df_lval;
|
|||
|
||||
static int set_lval_str(int token, const char *token_value);
|
||||
#define simple(token) set_lval_str(token, yytext)
|
||||
static GString *append_escaped_char(GString *str, char c);
|
||||
|
||||
/*
|
||||
* Sleazy hack to suppress compiler warnings in yy_fatal_error().
|
||||
|
@ -228,6 +229,10 @@ static int set_lval_str(int token, const char *token_value);
|
|||
|
||||
<DQUOTE>\\x[[:xdigit:]]{1,2} {
|
||||
/* hex sequence */
|
||||
/*
|
||||
* C standard does not place a limit on the number of hex
|
||||
* digits after \x... but we do. \xNN can have 1 or two Ns, not more.
|
||||
*/
|
||||
if (yyextra->raw_string) {
|
||||
g_string_append(yyextra->quoted_string, yytext);
|
||||
}
|
||||
|
@ -251,7 +256,7 @@ static int set_lval_str(int token, const char *token_value);
|
|||
g_string_append(yyextra->quoted_string, yytext);
|
||||
}
|
||||
else {
|
||||
g_string_append_c(yyextra->quoted_string, yytext[1]);
|
||||
append_escaped_char(yyextra->quoted_string, yytext[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,3 +347,40 @@ set_lval_str(int token, const char *token_value)
|
|||
df_lval->value = g_strdup(token_value);
|
||||
return token;
|
||||
}
|
||||
|
||||
static GString *
|
||||
append_escaped_char(GString *str, char c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'a':
|
||||
c = '\a';
|
||||
break;
|
||||
case 'b':
|
||||
c = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
c = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
c = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
c = '\r';
|
||||
break;
|
||||
case 't':
|
||||
c = '\t';
|
||||
break;
|
||||
case 'v':
|
||||
c = '\v';
|
||||
break;
|
||||
default:
|
||||
/* Unrecognized escapes are treated as a literal character.
|
||||
* If this is turned into an error instead (which is a backward
|
||||
* incompatibility but arguably the right thing to do)
|
||||
* we need to take care to accept all valid sequences
|
||||
* (like \" and \\). */
|
||||
break;
|
||||
}
|
||||
|
||||
return g_string_append_c(str, c);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue