ReVanced / revanced-patcher

💉 ReVanced Patcher used to patch Android applications
https://revanced.app
GNU General Public License v3.0
2.41k stars 200 forks source link

bug: incorrect decoding of paths to patches #295

Closed taku-nm closed 1 month ago

taku-nm commented 1 month ago

Bug description

Using CLI to patch, the patcher appears to be decoding the path to the patches as an URL.

To repro:

  1. create folder with spaces in path-name.
  2. save the patch bundle in said folder.
  3. save cli, integrations and the apk wherever (doesn't matter)
  4. attempt to patch normally. PS C:\rv-issue\example path with spaces> java -jar .\revanced-cli-4.6.0-all.jar patch .\yt.apk -b .\revanced-patches-4.7.0.jar -m .\revanced-integrations-1.8.0.apk -o yt-p.apk

Observe: Caused by: java.nio.file.NoSuchFileException: C:\rv-issue\example%20path%20with%20spaces\.\revanced-patches-4.7.0.jar

Error logs

PS C:\rv-issue\example path with spaces> java -jar .\revanced-cli-4.6.0-all.jar patch .\yt.apk -b .\revanced-patches-4.7.0.jar -m .\revanced-integrations-1.8.0.apk -o yt-p.apk
INFORMATION: Loading patches
INFORMATION: Decoding app manifest
INFORMATION: Spoof Wi-Fi connection excluded
INFORMATION: Remove screenshot restriction excluded
INFORMATION: Remove screen capture restriction excluded
INFORMATION: Export all activities excluded
INFORMATION: Enable Android debugging excluded
INFORMATION: Override certificate pinning excluded
INFORMATION: Hex excluded
INFORMATION: Change package name excluded
INFORMATION: Spoof SIM country excluded
INFORMATION: Predictive back gesture excluded
INFORMATION: Remove player controls background excluded
INFORMATION: Custom branding excluded
INFORMATION: Change header excluded
INFORMATION: Enable slide to seek excluded
INFORMATION: Setting patch options
INFORMATION: Merging integrations
INFORMATION: Deleting existing temporary files directory
INFORMATION: Decoding resources
INFORMATION: Executing patches
SCHWERWIEGEND: Alternative thumbnails failed:
app.revanced.patcher.patch.PatchException: 'Alternative thumbnails' depends on 'IntegrationsPatch' that raised an exception:
app.revanced.patcher.patch.PatchException: C:\rv-issue\example%20path%20with%20spaces\.\revanced-patches-4.7.0.jar
        at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Patcher.kt:187)
        at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Patcher.kt:155)
        at app.revanced.patcher.Patcher$apply$1.invokeSuspend(Patcher.kt:205)
        at app.revanced.patcher.Patcher$apply$1.invoke(Patcher.kt)
        at app.revanced.patcher.Patcher$apply$1.invoke(Patcher.kt)
        at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
        at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
        at app.revanced.cli.command.PatchCommand$run$4$1$1.invokeSuspend(PatchCommand.kt:303)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at app.revanced.cli.command.PatchCommand.run(PatchCommand.kt:302)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at app.revanced.cli.command.MainCommandKt.main(MainCommand.kt:12)
Caused by: java.nio.file.NoSuchFileException: C:\rv-issue\example%20path%20with%20spaces\.\revanced-patches-4.7.0.jar
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
        at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:199)
        at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1264)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:347)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:318)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:257)
        at app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.getPatchesManifestEntry(BaseIntegrationsPatch.kt:61)
        at app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.execute(BaseIntegrationsPatch.kt:44)
        at app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.execute(BaseIntegrationsPatch.kt:17)
        at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Patcher.kt:173)
        ... 25 more

Solution

No response

Additional context

No response

Acknowledgements

oSumAtrIX commented 1 month ago

The issue occured here: app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.getPatchesManifestEntry It is related to patches and already fixed in dev.