Improve performance of denylist patterns#780
Merged
westonruter merged 11 commits intodevelopfrom May 9, 2022
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #780 +/- ##
=============================================
+ Coverage 19.01% 19.62% +0.60%
Complexity 346 346
=============================================
Files 57 57
Lines 2324 2324
=============================================
+ Hits 442 456 +14
+ Misses 1882 1868 -14
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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 fixes an issue reported in a support topic where URLs with many query parameters can result in very slow response times by the service worker. Hat tip to @jeffposnick for pointing this out in GoogleChrome/workbox#3077 (comment).
The regular expressions in question are:
/\?(.+&)*wp_customize=//\?(.+&)*customize_changeset_uuid=/Given this example URL:
https://example.com/?ab=4&v0=56&u0=degrees+Celsius+%28%C2%B0C%29&f0=C&v1=60&u1=degrees+Celsius+%28%C2%B0C%29&f1=C&v2=0.0005&u2=per+degree+Celsius+%28%2F%C2%B0C%29&f2=CdT&v3=100&u3=centimetres+%28cm%29&f3=cm&u4=centimetres+%28cm%29&f4=cm&v5=100&u5=sq+centimetres+%28cm%C2%B2%29&f5=sqcm&v6=100.4&u6=sq+centimetres+%28cm%C2%B2%29&f6=sqcm&v7=100&u7=cu+centimetres+%28cc%2C+cm%C2%B3%29&f7=cucm&v8=100.6&u8=cu+centimetres+%28cc%2C+cm%C2%B3%29&f8=cucmThe patterns exhibit catastrophic backtracking:
This PR updates the patterns to be more efficient.
^\/wp\-admin($|\?.*|\/.*)[^\?]*.\.php($|\?.*).*\?(.*&)?(wp_service_worker)=.*\/wp\.serviceworker(\?.*)?$[^\?]*\/feed\/(\w+\/)?$\?(.+&)*wp_customize=\?(.+&)*customize_changeset_uuid=^\/wp\-json\/.*^\/wp\-admin($|\?|\/)^[^\?]*?\.php($|\?)\?(.*?&)?wp_service_worker=^[^\?]*?\/wp\.serviceworker(\?|$)^[^\?]*?\/feed\/(\w+\/)?$\?(.*?&)?wp_customize=\?(.*?&)?customize_changeset_uuid=^\/wp\-json\/