New issue
Advanced search Search tips

Issue 670852 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Removing filtered event handlers is busted

Project Member Reported by lazyboy@chromium.org, Dec 2 2016

Issue description

There are couple of bugs I noticed:

1. There's a typo in filter comparison code in browser process:
void EventRouter::RemoveFilterFromEvent(const std::string& event_name,
                                        const std::string& extension_id,
                                        const DictionaryValue* filter) {
...

  for (size_t i = 0; i < filter_list->GetSize(); i++) {
    DictionaryValue* filter = NULL;
    CHECK(filter_list->GetDictionary(i, &filter));
    if (filter->Equals(filter)) {  <- ###
      filter_list->Remove(i, NULL);
      break;
    }
  }
}


2. Filtered events are written in ExtensionPrefs under kFilteredEvents key.
But there's a bug  EventRouter::RemoveFilterFromEvent code that doesn't
read the entries properly if an event has "." in its name (which is most
events?)

void EventRouter::RemoveFilterFromEvent(const std::string& event_name,
                                        const std::string& extension_id,
                                        const DictionaryValue* filter) {
...
  if (!filtered_events ||
      !filtered_events->GetList(event_name, &filter_list)) { <- ###
...
}

<- ### needs to be GetListWithoutPathExpansion instead.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Dec 5 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/348e5ca732110d639d2aea576535c12383836ffb

commit 348e5ca732110d639d2aea576535c12383836ffb
Author: lazyboy <lazyboy@chromium.org>
Date: Mon Dec 05 21:43:29 2016

Fix bugs in filtered event removal code

1. There was a typo bug in EventRouter::RemoveFilterFromEvent()
2. The way we are writing and reading filtered events in ExtensionPrefs was inconsistent: using GetList vs GetListWithoutPathExpansion. This matters because event names, which are used as dictionary keys, generally contain dots in them. e.g. chrome.onFoo

Add unit tests to cover these changes.

BUG= 670852 
Test=None

Review-Url: https://codereview.chromium.org/2523913003
Cr-Commit-Position: refs/heads/master@{#436419}

[modify] https://crrev.com/348e5ca732110d639d2aea576535c12383836ffb/extensions/browser/event_router.cc
[modify] https://crrev.com/348e5ca732110d639d2aea576535c12383836ffb/extensions/browser/event_router.h
[modify] https://crrev.com/348e5ca732110d639d2aea576535c12383836ffb/extensions/browser/event_router_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment