forked from osmocom/wireshark
Be more forgiving about invalid Coloring Rules.
In ColoringRulesDialog: Only check a rule's display filter if that rule is enabled. This keeps us from disabling the OK button when we shouldn't. Adjust the "Your coloring rules file contains unknown rules" dialog text and buttons for accuracy. In color_filters.c: Don't try to compile disabled filters in color_filters_apply. Don't warn about disabled and invalid filters in read_filters_file. Bug: 12814 Change-Id: I7143bf8e7a6162d296f1e93769344b69763195c8 Reviewed-on: https://code.wireshark.org/review/17823 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
d2a59db2bb
commit
1320ea4d57
|
@ -386,6 +386,10 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
|
|||
gchar *local_err_msg = NULL;
|
||||
|
||||
g_assert(colorf->c_colorfilter == NULL);
|
||||
|
||||
/* If the filter is disabled it doesn't matter if it compiles or not. */
|
||||
if (colorf->disabled) return;
|
||||
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
|
||||
*err_msg = g_strdup_printf("Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, local_err_msg);
|
||||
|
@ -404,6 +408,10 @@ color_filter_validate_cb(gpointer filter_arg, gpointer err)
|
|||
gchar *local_err_msg;
|
||||
|
||||
g_assert(colorf->c_colorfilter == NULL);
|
||||
|
||||
/* If the filter is disabled it doesn't matter if it compiles or not. */
|
||||
if (colorf->disabled) return;
|
||||
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
|
||||
*err_msg = g_strdup_printf("Removing color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, local_err_msg);
|
||||
|
@ -621,7 +629,7 @@ read_filters_file(const gchar *path, FILE *f, gpointer user_data, color_filter_a
|
|||
dfilter_t *temp_dfilter;
|
||||
gchar *local_err_msg = NULL;
|
||||
|
||||
if (!dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
|
||||
if (!disabled && !dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
|
||||
ws_g_warning("Could not compile \"%s\" in colorfilters file \"%s\".\n%s",
|
||||
name, path, local_err_msg);
|
||||
g_free(local_err_msg);
|
||||
|
|
|
@ -221,7 +221,7 @@ typedef struct _e_prefs {
|
|||
gint gui_update_interval;
|
||||
gchar *saved_at_version;
|
||||
gboolean unknown_prefs; /* unknown or obsolete pref(s) */
|
||||
gboolean unknown_colorfilters; /* unknown or obsolete color filter(s) */
|
||||
gboolean unknown_colorfilters; /* Warn when saving unknown or obsolete color filters. */
|
||||
gboolean gui_qt_packet_list_separator;
|
||||
gboolean gui_packet_editor; /* Enable Packet Editor */
|
||||
elide_mode_e gui_packet_list_elide_mode;
|
||||
|
|
|
@ -175,8 +175,9 @@ void ColoringRulesDialog::updateWidgets()
|
|||
error_text = tr("the \"@\" symbol will be ignored.");
|
||||
}
|
||||
|
||||
// Check the rule's display filter syntax only if it's checked.
|
||||
QString display_filter = item->text(filter_col_);
|
||||
if (!display_filter.isEmpty()) {
|
||||
if (!display_filter.isEmpty() && item->checkState(name_col_) == Qt::Checked) {
|
||||
dfilter_t *dfilter;
|
||||
bool status;
|
||||
gchar *err_msg;
|
||||
|
@ -306,6 +307,7 @@ void ColoringRulesDialog::on_deleteToolButton_clicked()
|
|||
foreach (QTreeWidgetItem *ti, selected) {
|
||||
delete ti;
|
||||
}
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
void ColoringRulesDialog::on_copyToolButton_clicked()
|
||||
|
@ -360,9 +362,8 @@ void ColoringRulesDialog::on_buttonBox_accepted()
|
|||
QMessageBox mb;
|
||||
mb.setText(tr("Your coloring rules file contains unknown rules"));
|
||||
mb.setInformativeText(tr("Wireshark doesn't recognize one or more of your coloring rules. "
|
||||
"Saving will disable them."));
|
||||
mb.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
|
||||
mb.setDefaultButton(QMessageBox::Save);
|
||||
"They have been disabled."));
|
||||
mb.setStandardButtons(QMessageBox::Ok);
|
||||
|
||||
int result = mb.exec();
|
||||
if (result != QMessageBox::Save) return;
|
||||
|
@ -383,7 +384,6 @@ void ColoringRulesDialog::on_buttonBox_helpRequested()
|
|||
wsApp->helpTopicAction(HELP_COLORING_RULES_DIALOG);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ColoringRulesTreeDelegate
|
||||
// Delegate for editing coloring rule names and filters.
|
||||
|
@ -409,6 +409,8 @@ QWidget *ColoringRulesTreeDelegate::createEditor(QWidget *parent, const QStyleOp
|
|||
case filter_col_:
|
||||
{
|
||||
DisplayFilterEdit *dfe = new DisplayFilterEdit(parent);
|
||||
// It's possible to have an invalid filter and an enabled OK button at this point.
|
||||
// We might want to add a local slot for checking the filter status.
|
||||
connect(dfe, SIGNAL(textChanged(QString)), dfe, SLOT(checkDisplayFilter(QString)));
|
||||
dfe->setText(ti->text(filter_col_));
|
||||
w = (QWidget*) dfe;
|
||||
|
|
Loading…
Reference in New Issue