Changes between Initial Version and Version 1 of Ticket #6861


Ignore:
Timestamp:
08/15/2018 11:56:35 AM (20 months ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6861

    • Property Status changed from new to reviewing
  • Ticket #6861 – Description

    initial v1  
    11=== Background === 
    2 Currently the `serialize` method in the `Filter` class escapes any occurrence of an opening bracket in a filter (e.g. `##a[href^="http://ads."]`) with a backslash (`\`). At the time of parsing `patterns.ini`, the `INIParser` class unescapes the opening bracket before parsing the filter. 
     2Currently the `serializeFilters` function in `lib/subscriptionClasses.js` escapes any occurrence of an opening bracket in a filter (e.g. `##a[href^="http://ads."]`) with a backslash (`\`). At the time of parsing `patterns.ini`, the `INIParser` class unescapes the opening bracket before parsing the filter. 
    33 
    4 This escaping is not well thought out and would not work for snippet filters (#6538), nor for many other types of filters. There is no way to specify a literal `\[`sequence in a filter without messing it up, because when it is reloaded from disk it'll be read as `[` instead of `\[`. 
     4This escaping is not well thought out and would not work for snippet filters (#6538), nor for many other types of filters. There is no way to specify a literal `\[`sequence in a filter without messing it up, because when it is reloaded from disk it is read as `[` instead of `\[`. 
    55 
    66Escaping of an opening bracket is relevant only when it occurs at the beginning of a line optionally preceded only by whitespace; therefore, this escaping is mostly unnecessary. 
    77 
    88=== What to change === 
    9 In the `serialize` method in the `Filter` class, replace `filter.text.replace(/\[/g, "\\[")` with `filter.text.replace(/^(\s*)\[/, "$1\\[")`. 
     9In the `serializeFilters` function in `lib/subscriptionClasses.js`, replace `filter.text.replace(/\[/g, "\\[")` with `filter.text.replace(/^(\s*)\[/, "$1\\[")`. 
    1010 
    1111After a few releases, modify `INIParser` to only unescape the opening bracket when it occurs at the beginning of the line (optionally preceded by whitespace).