From 63e94c5af1cd48359b6b8b88dbb3d59e3d323efa Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 14 May 2015 15:00:07 -0700 Subject: [PATCH] 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 --- ui/qt/display_filter_edit.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ui/qt/display_filter_edit.cpp b/ui/qt/display_filter_edit.cpp index 415f805282..45ce0677ee 100644 --- a/ui/qt/display_filter_edit.cpp +++ b/ui/qt/display_filter_edit.cpp @@ -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; } } }