Remove deeply nested divs around img/noscript combinations#993
Open
gijsk wants to merge 2 commits intomozilla:mainfrom
Open
Remove deeply nested divs around img/noscript combinations#993gijsk wants to merge 2 commits intomozilla:mainfrom
gijsk wants to merge 2 commits intomozilla:mainfrom
Conversation
This CL fixes an issue where images nested within `<div>` elements inside a `<figure>` tag were being incorrectly removed by Readability's cleaning process. Specifically, a structure like `<figure><div><div><img></div></div></figure>` would first be transformed to `<figure><div><p><img></p></div></figure>`, and then the outer `<div>` (and its contents) would be erroneously identified as extraneous and removed. The fix introduces a targeted exception within _cleanConditionally(). It prevents the removal of `<div>` elements that meet the following criteria: * The element is a `<div>`. * The `<div>` is an ancestor of a `<figure>` element. * The `<div>` contains a single `<img>` element (potentially nested). Also add test case allrecipes-1 taken from: https://www.allrecipes.com/hot-honey-brussels-sprouts-recipe-11832010
Contributor
Author
|
(looks like maybe I should update the extended commit msg for 03abc3f still, before merging this) |
Contributor
|
NIT: Add function-level comment? Optional NIT: Perhaps Optional NIT: The outer Optional NIT: The unwrap loop (gut out Otherwise LGTM. |
Contributor
|
Hi, an updates in landing this change? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #989 .
This seems to also work, and also positively impacts some existing testcases. @samuelhuang could you confirm if this looks reasonable to you? There are minor markup changes in the
expected.htmlfor the newallrecipes-1testcase that you added (that strip the extraneous containers around theimg).