Skip to content

Commit

Permalink
fix: sanitize special characters in URLs (#21575)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotstone committed Apr 19, 2023
1 parent 14dbd5e commit 18d0fbc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/logger/utils.spec.ts
Expand Up @@ -37,6 +37,7 @@ describe('logger/utils', () => {
input | output
${' https://somepw@domain.com/gitlab/org/repo?go-get'} | ${' https://**redacted**@domain.com/gitlab/org/repo?go-get'}
${'https://someuser:somepw@domain.com'} | ${'https://**redacted**@domain.com'}
${'https://someuser:pass%word_with-speci(a)l&chars@domain.com'} | ${'https://**redacted**@domain.com'}
${'https://someuser:@domain.com'} | ${'https://**redacted**@domain.com'}
${'redis://:somepw@172.32.11.71:6379/0'} | ${'redis://**redacted**@172.32.11.71:6379/0'}
${'some text with\r\n url: https://somepw@domain.com\nand some more'} | ${'some text with\r\n url: https://**redacted**@domain.com\nand some more'}
Expand Down
2 changes: 1 addition & 1 deletion lib/logger/utils.ts
Expand Up @@ -244,7 +244,7 @@ export function validateLogLevel(logLevelToCheck: string | undefined): void {
}

// Can't use `util/regex` because of circular reference to logger
const urlRe = /[a-z]{3,9}:\/\/[-;:&=+$,\w]+@[a-z0-9.-]+/gi;
const urlRe = /[a-z]{3,9}:\/\/[^@/]+@[a-z0-9.-]+/gi;
const urlCredRe = /\/\/[^@]+@/g;

export function sanitizeUrls(text: string): string {
Expand Down

0 comments on commit 18d0fbc

Please sign in to comment.