From 2a842a1e14e1993eb028ae0bd1a93e227bb929a6 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 28 Feb 2024 22:50:19 +0100 Subject: [PATCH] fix(Override certificate pinning): Always overwrite with a generic network security configuration Previously some conditional checks prevented to patch YouTube for example. The current configuration should work globally for all apps. --- .../OverrideCertificatePinningPatch.kt | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt index 20f71425..dc300df4 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt @@ -4,6 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.debugging.EnableAndroidDebuggingPatch +import app.revanced.util.Utils.trimIndentMultiline import org.w3c.dom.Element import java.io.File @@ -32,10 +33,8 @@ object OverrideCertificatePinningPatch : ResourcePatch() { // In case the file does not exist create the "network_security_config.xml" file. File(resXmlDirectory, "network_security_config.xml").apply { - if (!exists()) { - createNewFile() - writeText( - """ + writeText( + """ @@ -55,21 +54,8 @@ object OverrideCertificatePinningPatch : ResourcePatch() { - """, - ) - } else { - // If the file already exists. - readText().let { text -> - if (!text.contains("")) { - writeText( - text.replace( - "", - "\n\n", - ), - ) - } - } - } + """.trimIndentMultiline(), + ) } } }