Skip to content

fix(utils): dirname and basename should handle Windows paths #8737

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

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Aug 5, 2023

The Electron SDK uses basename to get the file name without path but this returned the full path on Windows.

This PR adds Windows support to the regex and adds some tests.

// Truncate files names greater than 1024 characters to avoid regex dos
// https://github.com/getsentry/sentry-javascript/pull/8737#discussion_r1285719172
const truncated = filename.length > 1024 ? `<truncated>${filename.slice(-1024)}` : filename;
const parts = splitPathRe.exec(truncated);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on [library input](2) may run slow on strings with many repetitions of '.'. This [regular expression](1) that depends on [library input](3) may run slow on strings with many repetitions of '.'. This [regular expression](1) that depends on [library input](4) may run slow on strings with many repetitions of '.'. This [regular expression](1) that depends on [library input](5) may run slow on strings with many repetitions of '.'.
@AbhiPrasad AbhiPrasad merged commit a4ae291 into getsentry:develop Aug 8, 2023
@timfish timfish deleted the fix/dirname-basename-windows branch September 28, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants