fix(Sync for Reddit - Spoof client): Use www instead of ssl API to fix auth related issues (#5392)

This commit is contained in:
oSumAtrIX
2025-07-09 20:25:48 +02:00
committed by GitHub
parent cc548689ac
commit 6412a5cb1a
3 changed files with 48 additions and 3 deletions

View File

@@ -61,7 +61,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl
// region Patch miscellaneous.
// Reddit messed up and does not append a redirect uri to the authorization url to old.reddit.com/login.
// Replace old.reddit.com with ssl.reddit.com to fix this.
// Replace old.reddit.com with www.reddit.com to fix this.
buildAuthorizationStringFingerprint.method.apply {
val index = indexOfFirstInstructionOrThrow {
getReference<StringReference>()?.contains("old.reddit.com") == true
@@ -70,7 +70,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl
val targetRegister = getInstruction<OneRegisterInstruction>(index).registerA
replaceInstruction(
index,
"const-string v$targetRegister, \"https://ssl.reddit.com/api/v1/authorize.compact\"",
"const-string v$targetRegister, \"https://www.reddit.com/api/v1/authorize.compact\"",
)
}

View File

@@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patches.reddit.customclients.spoofClientPatch
import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch
import app.revanced.patches.shared.misc.string.replaceStringPatch
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@@ -13,7 +14,12 @@ import java.util.Base64
val spoofClientPatch = spoofClientPatch(
redirectUri = "http://redditsync/auth",
) { clientIdOption ->
dependsOn(disablePiracyDetectionPatch)
dependsOn(
disablePiracyDetectionPatch,
// Redirects from SSL to WWW domain are bugged causing auth problems.
// Manually rewrite the URLs to fix this.
replaceStringPatch("ssl.reddit.com", "www.reddit.com")
)
compatibleWith(
"com.laurencedawson.reddit_sync",

View File

@@ -0,0 +1,39 @@
package app.revanced.patches.shared.misc.string
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.ReferenceType
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
import kotlin.text.contains
fun replaceStringPatch(
from: String,
to: String
) = bytecodePatch(
description = "Replaces occurrences of '$from' with '$to' in string references.",
) {
dependsOn(
transformInstructionsPatch(
filterMap = filterMap@{ _, _, instruction, instructionIndex ->
if (instruction.opcode.referenceType != ReferenceType.STRING) return@filterMap null
val stringReference = instruction.getReference<StringReference>()!!.string
if (from !in stringReference) return@filterMap null
Triple(instructionIndex, instruction as OneRegisterInstruction, stringReference)
},
transform = transform@{ mutableMethod, entry ->
val (instructionIndex, instruction, stringReference) = entry
val newString = stringReference.replace(from, to)
mutableMethod.replaceInstruction(
instructionIndex,
"${instruction.opcode.name} v${instruction.registerA}, \"$newString\"",
)
},
)
)
}