Fix display filter completion behavior.

Allow completion for mismatched protocol and filter names.

Change-Id: I1d1e6b8f16d4d2d331b915c199f857835dcc1c53
Ping-bug: 11187
Reviewed-on: https://code.wireshark.org/review/8464
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-05-14 15:00:07 -07:00
parent 294706a1bf
commit 63e94c5af1
1 changed files with 5 additions and 9 deletions

View File

@ -464,19 +464,15 @@ void DisplayFilterEdit::buildCompletionList(const QString &field_word)
// Add fields only if we're past the protocol name and only for the
// current protocol.
// XXX This incorrectly skips over some fields since field and
// protocol names don't always match (see is_from_other_protocol_whitelist
// in tools/checkfiltername.pl). Unfortunately if we remove the
// startsWith check then completion becomes unbearably slow on
// Windows.
if (field_dots > pfname.count('.') && field_word.startsWith(pfname)) {
if (field_dots > pfname.count('.')) {
void *field_cookie;
const QByteArray fw_ba = field_word.toUtf8(); // or toLatin1 or toStdString?
const char *fw_utf8 = fw_ba.constData();
int fw_len = (int) strlen(fw_utf8);
for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) {
if (hfinfo->same_name_prev_id != -1) continue; // Ignore duplicate names.
QString abbrev = hfinfo->abbrev;
if (field_word.compare(abbrev)) field_list << abbrev;
if (!g_ascii_strncasecmp(fw_utf8, hfinfo->abbrev, fw_len)) field_list << hfinfo->abbrev;
}
}
}