mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
fix(reddit/sanitize-sharing-links): update patch to support latest app version (#2575)
This commit is contained in:
parent
f90d1a64ce
commit
737be9815b
3 changed files with 15 additions and 46 deletions
|
@ -1,22 +0,0 @@
|
||||||
package app.revanced.patches.reddit.misc.tracking.url.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object ShareLinkFactoryFingerprint : MethodFingerprint(
|
|
||||||
returnType = "L",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.CONST_STRING,
|
|
||||||
Opcode.CONST_STRING,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.APUT_OBJECT,
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.INVOKE_STATIC, // Returns the URL.
|
|
||||||
Opcode.MOVE_RESULT_OBJECT
|
|
||||||
),
|
|
||||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("ShareLinkFactory;") }
|
|
||||||
)
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package app.revanced.patches.reddit.misc.tracking.url.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object ShareLinkFormatterFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Ljava/lang/String;",
|
||||||
|
parameters = listOf("Ljava/lang/String;", "Ljava/util/Map;"),
|
||||||
|
strings = listOf("uri.getQueryParameters(name)", "uri.queryParameterNames", "newUriBuilder.build().toString()"),
|
||||||
|
)
|
|
@ -6,47 +6,29 @@ import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
|
||||||
import app.revanced.patches.reddit.misc.tracking.url.annotations.SanitizeUrlQueryCompatibility
|
import app.revanced.patches.reddit.misc.tracking.url.annotations.SanitizeUrlQueryCompatibility
|
||||||
import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkFactoryFingerprint
|
import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkFormatterFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("sanitize-sharing-links")
|
@Name("sanitize-sharing-links")
|
||||||
@Description("Removes (tracking) query parameters from the URLs when sharing links.")
|
@Description("Removes (tracking) query parameters from the URLs when sharing links.")
|
||||||
@SanitizeUrlQueryCompatibility
|
@SanitizeUrlQueryCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
@RequiresIntegrations
|
|
||||||
class SanitizeUrlQueryPatch : BytecodePatch(
|
class SanitizeUrlQueryPatch : BytecodePatch(
|
||||||
listOf(ShareLinkFactoryFingerprint)
|
listOf(ShareLinkFormatterFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
ShareLinkFactoryFingerprint.result?.let { result ->
|
|
||||||
result.mutableMethod.apply {
|
|
||||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
|
||||||
val urlRegister = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
ShareLinkFormatterFingerprint.result?.mutableMethod?.addInstructions(
|
||||||
insertIndex,
|
0,
|
||||||
"""
|
"return-object p0"
|
||||||
invoke-static {v$urlRegister}, $SANITIZE_METHOD_DESCRIPTOR
|
) ?: return ShareLinkFormatterFingerprint.toErrorResult()
|
||||||
move-result-object v$urlRegister
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} ?: return ShareLinkFactoryFingerprint.toErrorResult()
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
private const val SANITIZE_METHOD_DESCRIPTOR =
|
|
||||||
"Lapp/revanced/reddit/patches/SanitizeUrlQueryPatch;" +
|
|
||||||
"->stripQueryParameters(Ljava/lang/String;)Ljava/lang/String;"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue