Vazkii / CMPDL

Curse Modpack Downloader
224 stars 58 forks source link

Special characters such as apostrophes are already escaped #34

Closed kevinkjt2000 closed 5 years ago

kevinkjt2000 commented 6 years ago

I noticed that the URL below has %2527, when it should be left as %27

Downloading 221857/2521633
Project URL is http://minecraft.curseforge.com/projects/221857
File download URL is https://minecraft.curseforge.com/projects/pams-harvestcraft/files/2521633/download
Downloading Pam%27s HarvestCraft 1.12.2L.jar
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 403 for URL: https://media.forgecdn.net/files/2521/633/Pam%2527s+HarvestCraft+1.12.2L.jar
        at vazkii.cmpdl.CMPDL.main(CMPDL.java:49)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://media.forgecdn.net/files/2521/633/Pam%2527s+HarvestCraft+1.12.2L.jar
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at java.net.URL.openStream(URL.java:1045)
        at vazkii.cmpdl.CMPDL.downloadFileFromURL(CMPDL.java:369)
        at vazkii.cmpdl.CMPDL.downloadFile(CMPDL.java:325)
        at vazkii.cmpdl.CMPDL.downloadModpackFromManifest(CMPDL.java:218)
        at vazkii.cmpdl.CMPDL.downloadFromURL(CMPDL.java:107)
        at vazkii.cmpdl.CMPDL.main(CMPDL.java:47)
kevinkjt2000 commented 6 years ago

For reproducing: https://minecraft.curseforge.com/projects/forever-stranded-lost-souls v-1.0.4 is a pack that has 3 mods with % escaped characters in their names

mailleseraph commented 6 years ago

seems to be apostrophes that do it. all three mods(better builder's wands, Pam's harvest craft, and tinkers' addons) that error have an apostrophe in the namespace.

kevinkjt2000 commented 6 years ago

I believe it is more than just apostrophes. In general, it seems to be escaping the % symbols that are already escaping something else. ' becomes %27 normally, but for some reason it is being downloaded as %2527.

chorvus commented 6 years ago

The ^ in Material+Energy^Natural+Capital-0.11.04.zip is getting escaped to %255e instead of %5e too.

loa-in- commented 6 years ago

This also leaves empty jar files in instance directory. I can't connect to my Forever Stranded: LS server.

kevinkjt2000 commented 6 years ago

@loa-in- I believe the point of CMPDL is to download modpacks, not to help launch and/or connect to servers. So, it would be related to say that CMPDL fails to download special character jars because they are downloaded as empty files.

Saying you cannot connect to some server is only tangential to the purpose of CMPDL.

loa-in- commented 6 years ago

My point was, that the symptom was: server pack was different from client pack when using CMPDL with no clear indication why CMPDL would do that.

DDzwiedziu commented 6 years ago

I have a workaround. Assumes you have another place to download the empty files, like a previous version (YMMV) or a server instance. Requires parallel and renameutils. Run from the mods/ directory.

find . -size 0 -print0 | xargs -0 deurlname
find . -size 0 -print0 \
    | perl -pe 's/\.\///g' \
    | parallel -0I'!!' 'find $MOD_SRC_DIR -name "!!" -exec cp {} . \;'

If the server is not available trough local FS, but SSH to server is available then change the last line (beware, not tested):

| parallel -0I'!!' 'scp ${SERVER}:{$MOD_SRC_DIR}/"!!" .'

EDIT: added -print0 and -0 to the first command EDIT2: missing quotes

kevinkjt2000 commented 5 years ago

Seems this is fixed already