fix(all/packagename): Fix package name validation and provider authority matching

Allow uppercase letters in package name validation regex, since valid Java package names can start with uppercase.
Broaden provider authority replacement to also match authorities that contain or end with the original package name, not just those prefixed by it.
This commit is contained in:
PlayDay 2026-03-16 12:26:00 +01:00
parent c35b8b8e96
commit 462702c174

View file

@ -1,6 +1,9 @@
package app.revanced.patches.all.misc.packagename
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.Option
import app.revanced.patcher.patch.booleanOption
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.util.asSequence
import app.revanced.util.getNode
import org.w3c.dom.Element
@ -13,7 +16,7 @@ private val packageNameOption = stringOption(
description = "The name of the package to rename the app to.",
required = true,
) {
it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$"))
it == "Default" || it!!.matches(Regex("^[a-zA-Z]\\w*(\\.[a-zA-Z]\\w*)+$"))
}
/**
@ -111,7 +114,7 @@ val changePackageNamePatch = resourcePatch(
val provider = node as Element
val authorities = provider.getAttribute("android:authorities")
if (!authorities.startsWith("$packageName.")) continue
if ("$packageName." !in authorities && !authorities.endsWith(packageName)) continue
provider.setAttribute("android:authorities", authorities.replace(packageName, newPackageName))
}