Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#4067 closed change (fixed)

Make filter "keys" generated for element hiding filters numeric

Reported by: trev Assignee: trev
Priority: P3 Milestone:
Module: Core Keywords:
Cc: Blocked By:
Blocking: #4057 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29342974/

Description (last modified by trev)

Background

In order to achieve significant speedups in #4057, we should make sure that filterByKey used by the ElemHide component is an array - filter IDs (called "keys" here) should be numeric and consecutive.

What to change

Turn filterByKey into an array and assign keys by simply pushing into that array. However, as the website can potentially read out the keys on Firefox, it has to be ensured that guessing the filter from key isn't possible. The most efficient way seems to be adding filters in a pseudo-random order.

In particular, FilterListener has to be changed - rather than calling forEach to add all filters from a subscription, a new randomizeOrder function should be called. It will choose a random prime (one that the array length cannot be divided by) and a random starting point. It will then iterate through using the prime as the increase.

Hints for testers

This change affects element hiding functionality, it should still work correctly on startup, after adding or updating a filter subscription. Also, filter hits should be registered correctly in Firefox.

Change History (5)

comment:1 Changed 3 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 3 years ago by trev

  • Description modified (diff)

comment:3 Changed 3 years ago by abpbot

comment:4 Changed 3 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:5 Changed 3 years ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Element hiding seems to be working as expected except in Firefox 38-40, which is open as #4198.

ABP 1.12.0.1622
Chrome 30 / 40 / 50 / Windows 7
Opera 19 / 36 / Windows 7
Safari 7 / 9 / / OS X 10.9 / OS X 10.11

ABP 2.7.3.4184-beta
Firefox 41-45 / Windows 7

Note: See TracTickets for help on using tickets.