Skip to content

Commit

Permalink
Revert "Bypass font path prefix check in ResourcesCompat::loadFont" (
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-powell authored Jan 22, 2025
1 parent bc3dafc commit b338e55
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ internal abstract class ResourcesCompatVisitorFactory : AsmClassVisitorFactory<I
private class LoadFontVisitor(api: Int, delegate: MethodVisitor) : MethodVisitor(api, delegate) {
override fun visitMethodInsn(opcode: Int, owner: String, name: String, descriptor: String, isInterface: Boolean) {
if ("startsWith" == name) {
// Make calls to `startsWith` return true
super.visitInsn(Opcodes.POP) // Pop the arg being passed to `startsWith`, which is "res/"
super.visitInsn(Opcodes.POP) // Pop the receiver of `startsWith`, which is the font file path
super.visitLdcInsn(1) // Push `1` to the stack, as if `startsWith` returned true
super.visitMethodInsn(opcode, owner, "contains", "(Ljava/lang/CharSequence;)Z", isInterface)
} else {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ android {
kotlinOptions {
jvmTarget = libs.versions.javaTarget.get()
}

// For testing loading font resources from directories other than 'res/'
sourceSets.main.res.srcDirs += 'src/main/other_resources_dir'
}

dependencies {
Expand Down

0 comments on commit b338e55

Please sign in to comment.