Ticket #239 (closed defect: duplicate)
False positives when collapsing container of blocked elements
| Reported by: | esquifit+kabl@… | Owned by: | t-bone |
|---|---|---|---|
| Priority: | minor | Component: | Karma Blocker |
| Version: | 0.3.2 | Severity: | Broken |
| Keywords: | collapse | Cc: |
Description
Test case:
1) Define some rules for blocking 3rd party ads:
[Settings] threshold=10 cutoff=100 # 3rd party resources [Group] score=5 rule=$thirdParty==true # URLs with a word that starts "ad" or "banner" [Group] score=5 rule=$url=~'\b(ad[^d]|banner)'
2) Go to userscripts.org (with javascript enabled), enter something in the "Search" field (on the top right corner) and press 'Enter'.
3) Now:
If Kabl is disabled, the contents of a (dynamically loaded) iframe with search from google.com is shown as expected. Above the search results an input field and as 'Search" button are also displayed.
If Kabl is enabled, no input field and/or button is shown, the iframe is blocked as expected. However, the input field and the 'Search' button are not displayed although they lie outside the iframe.
Diagnostic:
The gKablPolicy.collapse method in kabl-policy.js climbs the DOM tree starting from the blocked element until it finds a container element that does not contain any text whose total length exceeds an arbitrary limit (currently hardcoded to 25 chars). However, it does not make provisions for significant non-textual html like a form. In effect, in the case above the DIV with id="content" contains the search form but it also has a text content consisting of white space with total length = 11, as a result of which it is being collapsed.