mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-25 03:31:03 +00:00
fix(Sync for Reddit - Spoof client): Use www instead of ssl API to fix auth related issues (#5392)
This commit is contained in:
@@ -61,7 +61,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl
|
|||||||
// region Patch miscellaneous.
|
// region Patch miscellaneous.
|
||||||
|
|
||||||
// Reddit messed up and does not append a redirect uri to the authorization url to old.reddit.com/login.
|
// 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 {
|
buildAuthorizationStringFingerprint.method.apply {
|
||||||
val index = indexOfFirstInstructionOrThrow {
|
val index = indexOfFirstInstructionOrThrow {
|
||||||
getReference<StringReference>()?.contains("old.reddit.com") == true
|
getReference<StringReference>()?.contains("old.reddit.com") == true
|
||||||
@@ -70,7 +70,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl
|
|||||||
val targetRegister = getInstruction<OneRegisterInstruction>(index).registerA
|
val targetRegister = getInstruction<OneRegisterInstruction>(index).registerA
|
||||||
replaceInstruction(
|
replaceInstruction(
|
||||||
index,
|
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\"",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patches.reddit.customclients.spoofClientPatch
|
import app.revanced.patches.reddit.customclients.spoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch
|
import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch
|
||||||
|
import app.revanced.patches.shared.misc.string.replaceStringPatch
|
||||||
import app.revanced.util.returnEarly
|
import app.revanced.util.returnEarly
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
@@ -13,7 +14,12 @@ import java.util.Base64
|
|||||||
val spoofClientPatch = spoofClientPatch(
|
val spoofClientPatch = spoofClientPatch(
|
||||||
redirectUri = "http://redditsync/auth",
|
redirectUri = "http://redditsync/auth",
|
||||||
) { clientIdOption ->
|
) { 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(
|
compatibleWith(
|
||||||
"com.laurencedawson.reddit_sync",
|
"com.laurencedawson.reddit_sync",
|
||||||
|
|||||||
@@ -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\"",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user