Skip to content

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

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

Merged
merged 1 commit into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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
Expand All @@ -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\"",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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\"",
)
},
)
)
}
Loading