dfilter: Improve some error messages

This commit is contained in:
João Valverde 2021-11-05 05:59:41 +00:00 committed by Wireshark GitLab Utility
parent fb490eb172
commit 2d45cb0881
4 changed files with 10 additions and 4 deletions

View File

@ -1131,7 +1131,7 @@ check_relation_matches(dfwork_t *dfw, stnode_t *st_node,
const char *patt;
if (stnode_type_id(st_arg2) != STTYPE_STRING) {
dfilter_fail(dfw, "Expected a string not %s", stnode_todisplay(st_arg2));
dfilter_fail(dfw, "Expected a double quoted string not %s", stnode_todisplay(st_arg2));
THROW(TypeError);
}

View File

@ -35,6 +35,12 @@ string_tostr(const void *data, gboolean pretty)
return g_strdup(data);
}
static char *
unparsed_tostr(const void *data, gboolean pretty _U_)
{
return g_strdup(data);
}
void
sttype_register_string(void)
@ -54,7 +60,7 @@ sttype_register_string(void)
string_new,
string_free,
string_dup,
string_tostr
unparsed_tostr
};
sttype_register(&string_type);

View File

@ -41,7 +41,7 @@ class case_range(unittest.TestCase):
def test_slice_unparsed_1(self, checkDFilterFail):
dfilter = "a == b[1]"
checkDFilterFail(dfilter, "Range is not supported for entity \"b\" of type UNPARSED")
checkDFilterFail(dfilter, "Range is not supported for entity b of type UNPARSED")
def test_slice_func_1(self, checkDFilterSucceed):
dfilter = "string(ipx.src.node)[3:2] == \"cc:dd\""

View File

@ -37,7 +37,7 @@ class case_syntax(unittest.TestCase):
def test_matches_2(self, checkDFilterFail):
dfilter = 'http.request.method matches HEAD'
checkDFilterFail(dfilter, 'Expected a string')
checkDFilterFail(dfilter, 'Expected a double quoted string')
def test_matches_3(self, checkDFilterFail):
dfilter = 'http.request.method matches "^HEAD" matches "^POST"'