Skip to content

Commit 654d091

Browse files
fix(YouTube - Sanitize sharing links): Handle non hierarchical urls
1 parent 98371be commit 654d091

File tree

1 file changed

+9
-0
lines changed
  • extensions/shared/library/src/main/java/app/revanced/extension/shared/privacy

1 file changed

+9
-0
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/privacy/LinkSanitizer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public String sanitizeUrlString(String url) {
3535

3636
public Uri sanitizeUri(Uri uri) {
3737
try {
38+
String scheme = uri.getScheme();
39+
if (scheme == null || !(scheme.equals("http") || scheme.equals("https"))) {
40+
// Opening YouTube share sheet 'other' option passes the video title as a URI.
41+
// Checking !uri.isHierarchical() works for all cases, except if the
42+
// video title starts with / and then it's hierarchical but still an invalid URI.
43+
Logger.printDebug(() -> "Ignoring uri: " + uri);
44+
return uri;
45+
}
46+
3847
Uri.Builder builder = uri.buildUpon().clearQuery();
3948

4049
if (!parametersToRemove.isEmpty()) {

0 commit comments

Comments
 (0)