Opened 4 years ago

Last modified 4 years ago

#4067 closed change

Make filter "keys" generated for element hiding filters numeric — at Version 2

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 (2)

comment:1 Changed 4 years ago by trev

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

comment:2 Changed 4 years ago by trev

  • Description modified (diff)
Note: See TracTickets for help on using tickets.