mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-24 02:42:11 +02:00
fix(Sanitize sharing links): patch doesn't work
This commit is contained in:
parent
1f7b6fd083
commit
ad06b62092
@ -18,7 +18,12 @@ import app.revanced.patches.shared.patch.tracking.AbstractSanitizeUrlQueryPatch
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SanitizeUrlQueryPatch : AbstractSanitizeUrlQueryPatch(
|
object SanitizeUrlQueryPatch : AbstractSanitizeUrlQueryPatch(
|
||||||
"$MISC_PATH/SanitizeUrlQueryPatch;"
|
"$MISC_PATH/SanitizeUrlQueryPatch;",
|
||||||
|
listOf(
|
||||||
|
CopyTextEndpointFingerprint,
|
||||||
|
ShareLinkFormatterFingerprint
|
||||||
|
),
|
||||||
|
null
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
super.execute(context)
|
super.execute(context)
|
||||||
|
@ -3,50 +3,21 @@ package app.revanced.patches.shared.patch.tracking
|
|||||||
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.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patches.shared.fingerprints.tracking.CopyTextEndpointFingerprint
|
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
abstract class AbstractSanitizeUrlQueryPatch(
|
abstract class AbstractSanitizeUrlQueryPatch(
|
||||||
private val descriptor: String,
|
private val descriptor: String,
|
||||||
private val additionalFingerprints: Set<MethodFingerprint> = emptySet()
|
private val sharedFingerprints: List<MethodFingerprint>,
|
||||||
|
private val additionalFingerprints: List<MethodFingerprint>? = null
|
||||||
) : BytecodePatch(
|
) : BytecodePatch(
|
||||||
buildSet {
|
buildSet {
|
||||||
add(CopyTextEndpointFingerprint)
|
addAll(sharedFingerprints)
|
||||||
additionalFingerprints.let(::addAll)
|
additionalFingerprints?.let(::addAll)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
private fun MethodFingerprint.additionalInvoke() {
|
|
||||||
result?.let {
|
|
||||||
it.mutableMethod.apply {
|
|
||||||
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
|
||||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if ((instruction as ReferenceInstruction).reference.toString() != "Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if (getInstruction(index + 1).opcode != Opcode.GOTO)
|
|
||||||
continue
|
|
||||||
|
|
||||||
val invokeInstruction = instruction as FiveRegisterInstruction
|
|
||||||
|
|
||||||
replaceInstruction(
|
|
||||||
index,
|
|
||||||
"invoke-static {v${invokeInstruction.registerC}, v${invokeInstruction.registerD}, v${invokeInstruction.registerE}}, "
|
|
||||||
+ "$descriptor->stripQueryParameters(Landroid/content/Intent;Ljava/lang/String;Ljava/lang/String;)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} ?: throw exception
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun MethodFingerprint.invoke() {
|
private fun MethodFingerprint.invoke() {
|
||||||
result?.let {
|
result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
@ -64,12 +35,7 @@ abstract class AbstractSanitizeUrlQueryPatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
CopyTextEndpointFingerprint.invoke()
|
for (fingerprint in sharedFingerprints)
|
||||||
|
fingerprint.invoke()
|
||||||
if (additionalFingerprints.isNotEmpty()) {
|
|
||||||
additionalFingerprints.forEach { fingerprint ->
|
|
||||||
fingerprint.additionalInvoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,20 @@
|
|||||||
package app.revanced.patches.youtube.misc.tracking
|
package app.revanced.patches.youtube.misc.tracking
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.shared.fingerprints.tracking.CopyTextEndpointFingerprint
|
||||||
import app.revanced.patches.shared.patch.tracking.AbstractSanitizeUrlQueryPatch
|
import app.revanced.patches.shared.patch.tracking.AbstractSanitizeUrlQueryPatch
|
||||||
import app.revanced.patches.youtube.misc.tracking.fingerprints.ShareLinkFormatterFingerprint
|
import app.revanced.patches.youtube.misc.tracking.fingerprints.ShareLinkFormatterFingerprint
|
||||||
import app.revanced.patches.youtube.misc.tracking.fingerprints.SystemShareLinkFormatterFingerprint
|
import app.revanced.patches.youtube.misc.tracking.fingerprints.SystemShareLinkFormatterFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
import app.revanced.util.exception
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Sanitize sharing links",
|
name = "Sanitize sharing links",
|
||||||
@ -43,14 +50,47 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SanitizeUrlQueryPatch : AbstractSanitizeUrlQueryPatch(
|
object SanitizeUrlQueryPatch : AbstractSanitizeUrlQueryPatch(
|
||||||
"$MISC_PATH/SanitizeUrlQueryPatch;",
|
"$MISC_PATH/SanitizeUrlQueryPatch;",
|
||||||
setOf(
|
listOf(CopyTextEndpointFingerprint),
|
||||||
|
listOf(
|
||||||
ShareLinkFormatterFingerprint,
|
ShareLinkFormatterFingerprint,
|
||||||
SystemShareLinkFormatterFingerprint
|
SystemShareLinkFormatterFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
"$MISC_PATH/SanitizeUrlQueryPatch;"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
super.execute(context)
|
super.execute(context)
|
||||||
|
|
||||||
|
arrayOf(
|
||||||
|
ShareLinkFormatterFingerprint,
|
||||||
|
SystemShareLinkFormatterFingerprint
|
||||||
|
).forEach { fingerprint ->
|
||||||
|
fingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
||||||
|
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if ((instruction as ReferenceInstruction).reference.toString() != "Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if (getInstruction(index + 1).opcode != Opcode.GOTO)
|
||||||
|
continue
|
||||||
|
|
||||||
|
val invokeInstruction = instruction as FiveRegisterInstruction
|
||||||
|
|
||||||
|
replaceInstruction(
|
||||||
|
index,
|
||||||
|
"invoke-static {v${invokeInstruction.registerC}, v${invokeInstruction.registerD}, v${invokeInstruction.registerE}}, "
|
||||||
|
+ "$INTEGRATIONS_CLASS_DESCRIPTOR->stripQueryParameters(Landroid/content/Intent;Ljava/lang/String;Ljava/lang/String;)V"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw fingerprint.exception
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings
|
* Add settings
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user