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

Correctly filter URL with an email address in it #1418

Closed
Tracked by #39
krystofwoldrich opened this issue May 2, 2023 · 1 comment · Fixed by #1424
Closed
Tracked by #39

Correctly filter URL with an email address in it #1418

krystofwoldrich opened this issue May 2, 2023 · 1 comment · Fixed by #1424
Assignees
Milestone

Comments

@krystofwoldrich
Copy link
Member

Description

Based on #1412 (comment)

This function doesn't filter out email addresses in URLs correctly.

static String _urlWithAuthRemoved(String url) {
final userInfoMatch = _authRegExp.firstMatch(url);
if (userInfoMatch != null && userInfoMatch.groupCount == 3) {
final userInfoString = userInfoMatch.group(2) ?? '';
final replacementString = userInfoString.contains(":")
? "[Filtered]:[Filtered]@"
: "[Filtered]@";
return '${userInfoMatch.group(1) ?? ''}$replacementString${userInfoMatch.group(3) ?? ''}';
} else {
return url;
}
}
}

Example URL: staging.server.com/api/v4/auth/password/reset/[email protected]

The output is https://[Filtered]@example.com but @example.com is part of the email and not the URL or userInfo.

@marandaneto
Copy link
Contributor

Btw also add tests for other symbols that may break the parsing or Regex, maybe there are more cases besides @.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants