ShayBox / Launcher-Curseforge

Integrates the CF Modpack install button to any MMC based launcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modpacks whose download URLs contain spaces fail

siphomateke opened this issue · comments

Version
MultiMC: 0.6.11-1344
MultiMC-Twitch: 1.1.3
OS: Kubuntu 20.04 (Linux)

Describe the bug
When the download URL returned from https://addons-ecs.forgesvc.ne contains a space, MultiMC-Twitch opens MultiMC with a URL missing all characters after the first space.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the CurseForge page for "All the Mods 3 Lite": https://www.curseforge.com/minecraft/modpacks/atm-3-lite
  2. Click on install and wait for MultiMC to open
  3. Observe that the import URL doesn't end in .zip
  4. Press OK in MultiMC
  5. See the error:
Job 'Modpack download' failed to process:
https://media.forgecdn.net/files/2756/992/All
  1. Observe that manually navigating to the download URL for the modpack https://addons-ecs.forgesvc.net/api/v2/addon/atm-3-lite/file/2756992/download-url returns the correct URL but with unescaped spaces https://edge.forgecdn.net/files/2756/992/All the Mods 3 Lite-v3.1.1.zip

That's very weird, we both use linux and I can't replicate it, maybe it was a problem with multimc not parsing spaces in flags or maybe there's something with my xdg open fixing it, but either way i'll replace spaces with %20, thanks for letting me know!

Okay, I added url parsing, since I can't reproduce this, see if this fixed the problem
linux-amd64.tar.gz

I did some more testing with the current version and have discovered more about reproducing it. It seems like the issue only occurs if MultiMC was already open before clicking "Install" on CurseForge. If MultiMC is not open before testing, the spaces cause no issue and the full correct import URL is used.

I also tried the new patched version but the behavior is the same. The issue is still not fixed.

Let me know if there are any logs I could provide to help debug the problem.

This is a problem with the multimc --import flag then, i'll tell the guy that added it

Found the bug. It comes from this line: https://github.com/MultiMC/MultiMC5/blob/5ca5661c23050d738f1d5f9ced5e7fb71eef3fce/application/MultiMC.cpp#L870

When a new instance of MultiMC is started while another instance of MultiMC is already running, the new instance will send a message to the main instance and exit. In this case, when running MultiMC --import <url> while MultiMC is already running, the new instance will send an import <url> message to the main instance to command it to show the "Import from zip" dialog and prefill the input box for the URL. Then, the main instance will receive the message, split it on each space, treat the first element as command identifier, and the second element as command argument.

However, it turns out that the QUrl class, which is used to parse the URL from the command-line argument, does not make valid encoded URLs but valid decoded URLs. Therefore, instead of replacing spaces with %20, it will actually replace each %20 with a space, hence this bug occurring, but only when MultiMC was already open.

^ As you can see above this message, I've submitted a pull request to the MultiMC repository to fix this bug.

PR is merged, problem is fixed with latest develop build