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:
parent
c35b8b8e96
commit
462702c174
1 changed files with 6 additions and 3 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue