report: avoid really slow regexes for long urls#14745
Merged
connorjclark merged 1 commit intomainfrom Apr 25, 2023
Merged
Conversation
adamraine
approved these changes
Feb 2, 2023
connorjclark
reviewed
Feb 2, 2023
| const MAX_LENGTH = 64; | ||
| if (parsedUrl.protocol !== 'data:') { | ||
| // Even non-data uris can be 10k characters long. | ||
| name = name.slice(0, 200); |
Collaborator
There was a problem hiding this comment.
for correctness within this function, this should 1) detect if string is greater than 200 characters and 2) if so, slice and append ELLIPSIS
otherwise we can show a cutoff URL without any indication we cut it off.
Collaborator
There was a problem hiding this comment.
perhaps this just works if you swap L214-223 to be first?
Collaborator
There was a problem hiding this comment.
nevermind, since this is taking the first 200 characters and later we trim to 64 this will never impact the result
connorjclark
requested changes
Feb 2, 2023
Closed
connorjclark
approved these changes
Apr 25, 2023
| const MAX_LENGTH = 64; | ||
| if (parsedUrl.protocol !== 'data:') { | ||
| // Even non-data uris can be 10k characters long. | ||
| name = name.slice(0, 200); |
Collaborator
There was a problem hiding this comment.
nevermind, since this is taking the first 200 characters and later we trim to 64 this will never impact the result
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.
I was looking at report perf and this regex stood out:
We already ran into this in #13785 (and fixed by #13791)
But.. theverge has a non-datauri URL that's 10kb long. and this nasty regex (my fault apparently) really doesn't enjoy working through such a big string.