🐛 Validator: support decimals for intrisic sizer dimensions#27544
Merged
sebastianbenz merged 1 commit intoampproject:masterfrom Apr 2, 2020
Merged
🐛 Validator: support decimals for intrisic sizer dimensions#27544sebastianbenz merged 1 commit intoampproject:masterfrom
sebastianbenz merged 1 commit intoampproject:masterfrom
Conversation
This also fixes hard coded image dimensions. Fixes ampproject#27528
|
Hey @ampproject/wg-caching, these files were changed: |
Gregable
approved these changes
Apr 2, 2020
westonruter
approved these changes
Apr 2, 2020
westonruter
reviewed
Apr 2, 2020
| attrs: { | ||
| name: "src" | ||
| value_regex: "data:image\\/svg\\+xml;charset=utf-8,<svg height=\"\\d+\" width=\"\\d+\" xmlns=\"http:\\/\\/www\\.w3\\.org\\/2000\\/svg\" version=\"1\\.1\"\\/>|data:image\\/svg\\+xml;charset=utf-8,<svg height='100' width='300' xmlns='http:\\/\\/www\\.w3\\.org\\/2000\\/svg' version='1\\.1'\\/>" | ||
| value_regex: "data:image\\/svg\\+xml;charset=utf-8,<svg height=\"\\d+(\\.\\d+)?\" width=\"\\d+(\\.\\d+)?\" xmlns=\"http:\\/\\/www\\.w3\\.org\\/2000\\/svg\" version=\"1\\.1\"\\/>|data:image\\/svg\\+xml;charset=utf-8,<svg height='\\d+(\\.\\d+)?\' width='\\d+(\\.\\d+)?\' xmlns='http:\\/\\/www\\.w3\\.org\\/2000\\/svg' version='1\\.1'\\/>" |
Member
There was a problem hiding this comment.
I just realized a way to make this more resilient to make this even more resilient to HTML mutations, perhaps the pattern should be modified like so:
value_regex: "data:image\\/svg\\+xml;charset=utf-8,<svg(\\s+(height=[\"']\\d+(\\.\\d+)?[\"']|width=[\"']\\d+(\\.\\d+)?[\"']|xmlns=[\"']http:\\/\\/www\\.w3\\.org\\/2000\\/svg[\"']|version=[\"']1\\.1[\"']))+\\s*(\\/>|></svg>)"
That would allow the order of the attributes to be modified freely. The whitespace would also be more forgiving. (It also combines the two patterns to use ['"] to represent the attributes. Granted this would allow something like width='1" causing a XML syntax error.) It also allows for a closing </svg> tag which actually should solve the problem of HTML minifiers from stripping self-closing slashes.
Regex without escaping:
data:image\/svg\+xml;charset=utf-8,<svg(\s+(height=["']\d+(\.\d+)?["']|width=["']\d+(\.\d+)?["']|xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']|version=["']1\.1["']))+\s*(\/>|></svg>)
Merged
Gregable
pushed a commit
that referenced
this pull request
Apr 6, 2020
* cl/304511035 Add CSS Validation test for declarations. * cl/305075265 Revision bump for #27544
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.
This also fixes hard coded image dimensions.
Fixes #27528