Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader: if an image URL can't be made safe, discard it before the post card type is chosen #46144

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

bluefuton
Copy link
Contributor

Discussed in p5PDj3-4Up-p2.

Changes proposed in this Pull Request

As of #45503, Reader's image filtering discards any image that has a query string after we’ve taken off known Photon size parameters like w and quality.

However, we don't do this check until quite late in the rendering process, after we've chosen what type of card to display. If there are images that don't meet the standard, they remain in post.images and we end up with missing images displayed like this:

screen-shot-2020-10-05-at-16 50 51

This PR adds an earlier safeImageUrl check to the 'keep valid images' rule, so any URL that we can't make safe is removed from post.images and post.content_images before we choose a post card type.

Testing instructions

Visit https://wordpress.com/read/feeds/98993195.

Without the PR, there'll be a bunch of empty images (all ads from a8.net with a query string):

screen-shot-2020-10-05-at-16 51 08

With the PR applied, there'll be fewer gallery cards, but no missing images.

Screen Shot 2020-10-05 at 18 24 23

You can also run the unit tests with yarn test-client client/lib/post-normalizer.

@bluefuton bluefuton added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Reader The reader site on Calypso. labels Oct 5, 2020
@bluefuton bluefuton added this to the Reader: Bug Backlog milestone Oct 5, 2020
@bluefuton bluefuton requested a review from hambai October 5, 2020 05:26
@bluefuton bluefuton self-assigned this Oct 5, 2020
@matticbot
Copy link
Contributor

@bluefuton bluefuton requested a review from a team October 5, 2020 05:26
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~13 bytes added 📈 [gzipped])

name         parsed_size           gzip_size
entry-main         +26 B  (+0.0%)       +6 B  (+0.0%)
entry-login        +26 B  (+0.0%)       +7 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~7 bytes added 📈 [gzipped])

name    parsed_size           gzip_size
reader        +20 B  (+0.0%)       +7 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~21 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-design-blocks                               +20 B  (+0.0%)       +7 B  (+0.0%)
async-load-components-web-preview-component            +20 B  (+0.0%)       +7 B  (+0.0%)
async-load-blocks-support-article-dialog-dialog        +20 B  (+0.0%)       +7 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@krymson24
Copy link
Contributor

@bluefuton works as expected!

Screen Shot 2020-10-08 at 12 29 04 AM

@bluefuton bluefuton added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 8, 2020
@bluefuton
Copy link
Contributor Author

Thanks for the review @krymson24 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants