-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5208 from Stypox/recaptcha-pbj
Remove pbj=1 parameter from YouYube urls in recaptcha activity
- Loading branch information
Showing
2 changed files
with
38 additions
and
6 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
27 changes: 27 additions & 0 deletions
27
app/src/test/java/org/schabi/newpipe/ReCaptchaActivityTest.kt
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.schabi.newpipe | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.schabi.newpipe.ReCaptchaActivity.YT_URL | ||
|
||
class ReCaptchaActivityTest { | ||
private fun assertSanitized(expected: String, actual: String?) { | ||
assertEquals(expected, ReCaptchaActivity.sanitizeRecaptchaUrl(actual)) | ||
} | ||
|
||
@Test fun `null, empty or blank url is sanitized correctly`() { | ||
assertSanitized(YT_URL, null) | ||
assertSanitized(YT_URL, "") | ||
assertSanitized(YT_URL, " \n \t ") | ||
} | ||
|
||
@Test fun `YouTube url containing pbj=1 is sanitized correctly`() { | ||
val sanitizedUrl = "https://m.youtube.com/results?search_query=test" | ||
assertSanitized(sanitizedUrl, "https://m.youtube.com/results?search_query=test") | ||
assertSanitized(sanitizedUrl, "https://m.youtube.com/results?search_query=test&pbj=1&pbj=1") | ||
assertSanitized(sanitizedUrl, "https://m.youtube.com/results?pbj=1&search_query=test") | ||
assertSanitized("pbj://pbj.pbj.pbj/pbj", "pbj://pbj.pbj.pbj/pbj?pbj=1") | ||
assertSanitized("http://www.host.com/b?p1=7&p2=9", "http://www.host.com/b?p1=7&pbj=1&p2=9") | ||
assertSanitized("http://www.host.com/a?pbj=0", "http://www.host.com/a?pbj=0") | ||
} | ||
} |