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

report: avoid really slow regexes for long urls #14745

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class Util {

const MAX_LENGTH = 64;
if (parsedUrl.protocol !== 'data:') {
// Even non-data uris can be 10k characters long.
name = name.slice(0, 200);
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps this just works if you swap L214-223 to be first?

Copy link
Collaborator

Choose a reason for hiding this comment

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

nevermind, since this is taking the first 200 characters and later we trim to 64 this will never impact the result

// Always elide hexadecimal hash
name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
// Also elide other hash-like mixed-case strings
Expand Down