-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
16caf64
to
450e68a
Compare
@@ -175,7 +177,7 @@ function determineNaturalSize(url) { | |||
} | |||
|
|||
/** | |||
* @param {LH.Crdp.CSS.CSSStyle} [style] | |||
* @param {LH.Crdp.CSS.CSSStyle|undefined} style |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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 :)
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