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

fix(Tumblr - Fix old versions): Improve reliability by removing remnances of Tumblr Live #2988

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.tumblr.fixes.fingerprints.HttpPathParserFingerprint
import app.revanced.patches.tumblr.fixes.fingerprints.AddQueryParamFingerprint
import app.revanced.patches.tumblr.fixes.fingerprints.HttpPathParserFingerprint
import app.revanced.util.exception

@Patch(
name = "Fix old versions",
description = "Fixes old versions of the app (v33.2 and earlier) breaking due to Tumblr removing remnants of Tumblr" +
" Live from the API, which causes many requests to fail. This patch has no effect on newer versions of the app.",
" Live from the API, which causes many requests to fail. This patch has no effect on newer versions of the app.",
compatiblePackages = [CompatiblePackage("com.tumblr")],
use = false,
)
Expand All @@ -21,41 +21,40 @@ object FixOldVersionsPatch : BytecodePatch(
setOf(HttpPathParserFingerprint, AddQueryParamFingerprint),
) {
override fun execute(context: BytecodeContext) {
val blockedStrings = listOf(
",?live_now", ",?live_streaming_user_id"
val liveQueryParameters = listOf(
",?live_now",
",?live_streaming_user_id",
)

HttpPathParserFingerprint.result?.let {
val endIndex = it.scanResult.patternScanResult!!.endIndex
// Remove each of the blockedStrings elements from statically defined request URLs
for (blockedString in blockedStrings) {
// Remove the live query parameters from the path.
leumasme marked this conversation as resolved.
Show resolved Hide resolved
for (liveQueryParameter in liveQueryParameters) {
it.mutableMethod.addInstructions(
endIndex + 1,
"""
# Remove blocked string from URL path (p2)
# path = path.replace(blockedString, "")
const-string p1, "$blockedString"
# urlPath = urlPath.replace(liveQueryParameter, "")
const-string p1, "$liveQueryParameter"
const-string p3, ""
invoke-virtual {p2, p1, p3}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
move-result-object p2
"""
""",
)
}
} ?: throw HttpPathParserFingerprint.exception

AddQueryParamFingerprint.result?.let {
// Remove each of the blockedStrings elements when passed in as a @Query argument
for (blockedString in blockedStrings) {
// Remove the live query parameters when passed via the @Query annotation.
leumasme marked this conversation as resolved.
Show resolved Hide resolved
for (liveQueryParameter in liveQueryParameters) {
it.mutableMethod.addInstructions(
0,
"""
# Remove blocked string from query parameter value (p2)
# value = value.replace(blockedString, "")
const-string v0, "$blockedString"
# queryParameterValue = queryParameterValue.replace(liveQueryParameter, "")
leumasme marked this conversation as resolved.
Show resolved Hide resolved
const-string v0, "$liveQueryParameter"
const-string v1, ""
invoke-virtual {p2, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
move-result-object p2
"""
""",
)
}
} ?: throw AddQueryParamFingerprint.exception
Expand Down
Loading