-
-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lcian/feat/report-missing-integrations
- Loading branch information
Showing
5 changed files
with
196 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,7 @@ class UrlUtilsTest { | |
} | ||
|
||
@Test | ||
fun `splits url without query or fragment and no authority`() { | ||
fun `splits url without query or fragment and no user info`() { | ||
val urlDetails = UrlUtils.parse( | ||
"https://sentry.io" | ||
) | ||
|
@@ -161,30 +161,179 @@ class UrlUtilsTest { | |
assertEquals("top", urlDetails.fragment) | ||
} | ||
|
||
// Fragment is allowed to contain '?' according to RFC 3986 | ||
@Test | ||
fun `no details extracted with query after fragment`() { | ||
fun `extracts details with question mark after fragment`() { | ||
val urlDetails = UrlUtils.parse( | ||
"https://user:[email protected]#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("https://[Filtered]:[Filtered]@sentry.io", urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details with question mark after fragment without user info`() { | ||
val urlDetails = UrlUtils.parse( | ||
"https://sentry.io#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("https://sentry.io", urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `no details extracted from malformed url due to invalid protocol`() { | ||
val urlDetails = UrlUtils.parse( | ||
"htps://[email protected]#fragment?q=1&s=2&token=secret" | ||
) | ||
assertNull(urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertNull(urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `no details extracted with query after fragment without authority`() { | ||
fun `no details extracted from malformed url due to # symbol in fragment`() { | ||
val urlDetails = UrlUtils.parse( | ||
"https://sentry.io#fragment?q=1&s=2&token=secret" | ||
"https://example.com#hello#fragment" | ||
) | ||
assertNull(urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertNull(urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `no details extracted from malformed url`() { | ||
fun `strips empty user info`() { | ||
val urlDetails = UrlUtils.parse( | ||
"htps://[email protected]#fragment?q=1&s=2&token=secret" | ||
"https://@sentry.io?query=a#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("https://[Filtered]@sentry.io", urlDetails.url) | ||
assertEquals("query=a", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details from relative url with leading @ symbol`() { | ||
val urlDetails = UrlUtils.parse( | ||
"@@sentry.io/pages/10?query=a#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("@@sentry.io/pages/10", urlDetails.url) | ||
assertEquals("query=a", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details from relative url with leading question mark`() { | ||
val urlDetails = UrlUtils.parse( | ||
"?query=a#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("", urlDetails.url) | ||
assertEquals("query=a", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in path`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com/api/v4/auth/password/reset/[email protected]" | ||
)!! | ||
assertEquals("https://staging.server.com/api/v4/auth/password/reset/[email protected]", urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertNull(urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in path with fragment`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com/api/v4/auth/password/reset/[email protected]#top" | ||
)!! | ||
assertEquals("https://staging.server.com/api/v4/auth/password/reset/[email protected]", urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertEquals("top", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in path with query and fragment`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com/api/v4/auth/password/reset/[email protected]?a=b&c=d#top" | ||
)!! | ||
assertEquals("https://staging.server.com/api/v4/auth/password/reset/[email protected]", urlDetails.url) | ||
assertEquals("a=b&c=d", urlDetails.query) | ||
assertEquals("top", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in query`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com/[email protected]" | ||
)!! | ||
assertEquals("https://staging.server.com/", urlDetails.url) | ||
assertEquals("[email protected]", urlDetails.query) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in fragment`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com#[email protected]" | ||
)!! | ||
assertEquals("https://staging.server.com", urlDetails.url) | ||
assertEquals("[email protected]", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not filter email address in fragment with query`() { | ||
val urlDetails = UrlUtils.parseNullable( | ||
"https://staging.server.com?q=a&b=c#[email protected]" | ||
)!! | ||
assertEquals("https://staging.server.com", urlDetails.url) | ||
assertEquals("q=a&b=c", urlDetails.query) | ||
assertEquals("[email protected]", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details from relative url with email in path`() { | ||
val urlDetails = UrlUtils.parse( | ||
"/emails/[email protected]?query=a&b=c#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("/emails/[email protected]", urlDetails.url) | ||
assertEquals("query=a&b=c", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details from relative url with email in query`() { | ||
val urlDetails = UrlUtils.parse( | ||
"users/[email protected]&b=c#fragment?q=1&s=2&token=secret" | ||
) | ||
assertEquals("users/10", urlDetails.url) | ||
assertEquals("[email protected]&b=c", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&token=secret", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts details from relative url with email in fragment`() { | ||
val urlDetails = UrlUtils.parse( | ||
"users/[email protected]&b=c#fragment?q=1&s=2&[email protected]" | ||
) | ||
assertEquals("users/10", urlDetails.url) | ||
assertEquals("[email protected]&b=c", urlDetails.query) | ||
assertEquals("fragment?q=1&s=2&[email protected]", urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `extracts path from file url`() { | ||
val urlDetails = UrlUtils.parse( | ||
"file:///users/sentry/text.txt" | ||
) | ||
assertEquals("file:///users/sentry/text.txt", urlDetails.url) | ||
assertNull(urlDetails.query) | ||
assertNull(urlDetails.fragment) | ||
} | ||
|
||
@Test | ||
fun `does not extract details from websockets uri`() { | ||
val urlDetails = UrlUtils.parse( | ||
"wss://example.com/socket" | ||
) | ||
assertNull(urlDetails.url) | ||
assertNull(urlDetails.query) | ||
|