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

core(image-elements): do not set untrusted natural dimensions #11457

Merged
merged 2 commits into from
Sep 28, 2020

Conversation

patrickhulce
Copy link
Collaborator

Summary
A band-aid for #11450 to not set the natural dimensions if they were from a situation we know to provide incorrect natural dimensions. A proper fix for using the correct dimensions requires a much broader fixes across LH in #11454.

Related Issues/PRs
fixes #11450

@patrickhulce patrickhulce requested a review from a team as a code owner September 18, 2020 16:34
@patrickhulce patrickhulce requested review from paulirish and removed request for a team September 18, 2020 16:34
@@ -175,7 +177,7 @@ function determineNaturalSize(url) {
}

/**
* @param {LH.Crdp.CSS.CSSStyle} [style]
* @param {LH.Crdp.CSS.CSSStyle|undefined} style
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive by fix, vscode flags this as a ts error

@@ -191,7 +193,7 @@ function findSizeDeclaration(style, property) {
/**
* Finds the most specific directly matched CSS font-size rule from the list.
*
* @param {Array<LH.Crdp.CSS.RuleMatch>} [matchedCSSRules]
* @param {Array<LH.Crdp.CSS.RuleMatch>|undefined} matchedCSSRules
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive by fix, vscode flags this as a ts error

@@ -346,7 +348,6 @@ class ImageElements extends Gatherer {
// or it's not in the top 50 largest images.
if (
(element.isPicture || element.isCss || element.srcset) &&
networkRecord &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusion fix, we always default networkRecord to {} if we couldn't find one so this check does nothing

@@ -188,6 +188,13 @@ class Server {
}

function sendRedirect(url) {
if (url.split('').some(char => char.charCodeAt(0) > 256)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only semi-related, at one point debugging I put a redirect that contained non-ascii characters and it crashed the server entirely, which is suboptimal. returning a 500 makes more sense :)

@devtools-bot devtools-bot merged commit 3ffb99a into master Sep 28, 2020
@devtools-bot devtools-bot deleted the bandaid_image_elements branch September 28, 2020 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Displays images with inappropriate size
5 participants