-
-
Notifications
You must be signed in to change notification settings - Fork 426
feat(Spotify): Add Sanitize sharing links
patch
#4829
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
feat(Spotify): Add Sanitize sharing links
patch
#4829
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
...ify/src/main/java/app/revanced/extension/spotify/misc/privacy/SanitizeSharingLinksPatch.java
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Outdated
Show resolved
Hide resolved
Actually, @anddea had already added a similar patch to his RVX fork. Your patch is cleaner in the patches side, but about the extensions code, anddea version is better. I think the patch description is also anddea version is better. (I wonder why he added the Spotify patches to his RVX fork instead of PRing to official ReVanced alongside with the official ReVanced's Unlock Premium patch 🤔) |
The extension code from this PR follows URL specs. This is correct. Arbitrary string manipulation is not recommended |
I wrote this on discord already, but there's a couple of sanitize links patched that may be abstractable into a generic sanitize link patch for code deduplication |
The extension method done by anddea is basically wrong tho.. it's simply returning everything before |
I didn't know, sorry |
That's true, I hadn't considered that aspect. But I've never come across links like that. Do you have any examples?
I can simplify my patch. I overcomplicated the fingerprint and invokeDirectIndex during testing to match more cases and ensure I hit the right spot on the first try. I just never simplified it afterward because there wasn’t really a reason to, but yeah, it can be drastically simplified. I even have both the fingerprint and the patch in a single file, which might be considered as not the best practice by some people. But why are there two instructions, though? I’ve been using just one, and I haven’t run into any issues so far. Am I missing something?
I don't mind if anyone moves all my patches here or even rewrites it in a better way. I just don't want to make the same thing twice, I experiment in my repo where I can push immediately. |
Can this be merged for now, or should I convert this to a generic patch still in this same PR? |
What's here is ok. |
|
Not sure if this part is really necessary, spamming the URL just makes it even longer (since a Spotify link already opens the album directly). But I'll merge these changes into my repo anyway. Genuine question though, why inject two separate calls to sanitizeUrl? Even though the end user won't notice any big impact, creating the Uri, Uri.Builder, and other objects is already less performant than raw string manipulation, and here it's doing all that twice. Seems like overhead that should be avoided if possible. |
That seems like a huge micro optimization which shouldn't be considered. The user will click little times in the share button, that won't have any issues. |
Sure (why huge though?)
Still, with one injection in my repo, there were no issues (if I'm not missing anything, never got any reports). So if possible, then why? |
I wasn't sure whether fullUrl should be sanitized too, so I figured its better to be safe than sorry |
It appears Search for string |
Modifying the url passed to the intent works, but only if the Android share sheet is used (the quick links first shown are still unpatched). |
This reverts commit 05ca46d.
I meant to push to my own branch, but the commit here shows the what I intended. There's a few places left to patch (X and TikTok), but they are simple and it would not touch remote logging functionality. (Edit: X uses the Android share sheet, and it's already patched with the code in the commit above). The downside is the patch will require half a dozen fingerprints, and if quick share targets are added they won't be modified until the patch is updated. |
It looks like the TikTok share code is dead legacy code, or at least it's not functional with Android 15. I installed TikTok but it does not show as a quick share action in Spotify. So the commit above may be all that's needed. |
This is quite complicated, there are many targets involved: Copy Link, SMS, WhatsApp, Instagram, X, other apps, and "More" (which opens the Android share sheet for additional apps). In the end, does it really matter if Spotify receives these modified URLs? If they notice and decide to change the sharing logic, they could just as easily check whatever method is being used here and update their code in a future release.
With the current implementation (at least in my patch), URLs are already being sanitized for all share targets, and this comes at a relatively low cost. Even if Spotify breaks this patch by altering the output format or whatever, the impact is less severe compared to the effort required to implement a more complex solution that could still be broken just as easily. |
I have it working with only 2 changes. Copy url, and share sheet. The share sheet is used for all sharing except copy url. I agree it's more complicated, but I think it's worth it to make the app behave closer to unmodified. It will remove the chance of user accounts acting strange because the reported share data is missing key information. |
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Outdated
Show resolved
Hide resolved
...ify/src/main/java/app/revanced/extension/spotify/misc/privacy/SanitizeSharingLinksPatch.java
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/extension/ExtensionPatch.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/Fingerprints.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
…acy/SanitizeSharingLinksPatch.kt Co-authored-by: oSumAtrIX <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick to match all the other patches in Spotify, which all include new lines at the end of the files
...ify/src/main/java/app/revanced/extension/spotify/misc/privacy/SanitizeSharingLinksPatch.java
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
…y/misc/privacy/SanitizeSharingLinksPatch.java Co-authored-by: Nuckyz <[email protected]>
…acy/SanitizeSharingLinksPatch.kt Co-authored-by: Nuckyz <[email protected]>
# [5.23.0-dev.4](v5.23.0-dev.3...v5.23.0-dev.4) (2025-05-06) ### Features * **Spotify:** Add `Sanitize sharing links` patch ([#4829](#4829)) ([2e3511d](2e3511d))
# [5.23.0](v5.22.0...v5.23.0) (2025-05-10) ### Bug Fixes * Correct incorrect fingerprint ([c3bab89](c3bab89)) * Fix incorrect fingerprints ([#4917](#4917)) ([49ca329](49ca329)) * **Spotify - Unlock Spotify Premium:** Remove pop up premium ads ([#4842](#4842)) ([00aa200](00aa200)) * **YouTube:** Improve litho filtering performance ([#4904](#4904)) ([7b43986](7b43986)) * **YouTube:** Simplify litho filtering patch ([#4910](#4910)) ([bd53955](bd53955)) ### Features * **Lightroom:** Constrain patches to last working version ([efef03b](efef03b)) * **Pandora:** Add `Disable audio ads` and `Unlimited skips` patch ([#4841](#4841)) ([0cf7a4c](0cf7a4c)) * **Prime Video:** Add `Skip ads` patch ([#4824](#4824)) ([bb672c4](bb672c4)) * **Spotify:** Add `Sanitize sharing links` patch ([#4829](#4829)) ([2e3511d](2e3511d))
Removes user tracking data from shared urls.
For example,
https://open.spotify.com/track/0gJvyZ5a4d2UQd2ZFWbiGE?si=YCFUrazkSNqfK76YgbpxpA
Then becomes:
https://open.spotify.com/track/0gJvyZ5a4d2UQd2ZFWbiGE