Skip to content

Commit 7a45307

Browse files
committed
fix url encoding
1 parent cefa10e commit 7a45307

File tree

4 files changed

+129
-17
lines changed

4 files changed

+129
-17
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repositories {
2828

2929
group = 'net.minecraftforgefrance'
3030
archivesBaseName = 'installer'
31-
version = '1.0.8'
31+
version = '1.0.9'
3232
targetCompatibility = '1.6'
3333
sourceCompatibility = '1.6'
3434

build.gradle~

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
apply plugin: 'maven'
2+
apply plugin: 'java'
3+
apply plugin: 'eclipse'
4+
apply plugin: 'idea'
5+
6+
buildscript {
7+
repositories {
8+
mavenCentral()
9+
}
10+
dependencies {
11+
classpath 'net.sf.proguard:proguard-gradle:5.2.1'
12+
}
13+
}
14+
15+
repositories {
16+
mavenCentral()
17+
maven {
18+
url "https://libraries.minecraft.net/"
19+
}
20+
maven {
21+
url "http://files.minecraftforgefrance.fr/maven/"
22+
}
23+
flatDir {
24+
name "fileRepo"
25+
dirs "repo"
26+
}
27+
}
28+
29+
group = 'net.minecraftforgefrance'
30+
archivesBaseName = 'installer'
31+
version = '1.0.8'
32+
targetCompatibility = '1.6'
33+
sourceCompatibility = '1.6'
34+
35+
dependencies {
36+
compile 'net.sf.jopt-simple:jopt-simple:4.5'
37+
compile 'argo:argo:2.25_fixed'
38+
compile 'com.google.guava:guava:14.0'
39+
compile 'org.tukaani:xz:1.3'
40+
compile 'net.minecraft:launchwrapper:1.9'
41+
compile 'utybo:minkj:1.0'
42+
}
43+
44+
task fatJar(type: Jar, dependsOn: jar) {
45+
inputs.file jar.archivePath
46+
from(configurations.compile.collect { zipTree(it).matching { include '**/*.class' } })
47+
manifest { attributes 'Main-Class': 'fr.minecraftforgefrance.installer.Installer' }
48+
}
49+
50+
fatJar.doFirst {
51+
from zipTree(jar.archivePath)
52+
}
53+
54+
task shrinkJar(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
55+
inputs.file fatJar.archivePath
56+
ext {
57+
outDir = file("${buildDir}/proguard")
58+
obfuscatedJar = "${outDir}/${jar.baseName}.jar"
59+
}
60+
outDir.mkdirs()
61+
62+
injars jar.archivePath
63+
outjars obfuscatedJar
64+
libraryjars configurations.compile
65+
configuration 'proguard.pro'
66+
}
67+
68+
task shrinkOutput(type: Jar, dependsOn: shrinkJar) {
69+
classifier = 'shrunk'
70+
from zipTree(shrinkJar.obfuscatedJar)
71+
manifest { attributes 'Main-Class': 'fr.minecraftforgefrance.installer.Installer' }
72+
}
73+
74+
task updaterJar(type: Jar, dependsOn: "jar"){
75+
from project.sourceSets.main.output
76+
archiveName = "updater-${project.version}-thin.jar"
77+
include "fr/minecraftforgefrance/updater/**"
78+
include "fr/minecraftforgefrance/common/**"
79+
include "langs/**"
80+
}
81+
82+
task fullUpdaterJar(type: Jar, dependsOn: "updaterJar"){
83+
inputs.file jar.archivePath
84+
from(configurations.compile.collect { zipTree(it).matching {
85+
include 'org/tukaani/**/*.class'
86+
include 'utybo/minkj/**/*.class'
87+
} })
88+
archiveName = "updater-${project.version}-full.jar"
89+
}
90+
91+
fullUpdaterJar.doFirst {
92+
from zipTree(updaterJar.archivePath)
93+
}
94+
95+
artifacts {
96+
archives fatJar
97+
archives shrinkOutput
98+
archives updaterJar
99+
archives fullUpdaterJar
100+
}
101+
102+
jar {
103+
classifier = 'thin'
104+
exclude 'argo/**'
105+
exclude 'fr/minecraftforgefrance/updater/**'
106+
manifest { attributes 'Main-Class': 'fr.minecraftforgefrance.installer.Installer' }
107+
}
108+
109+
task wrapper(type: Wrapper) {
110+
gradleVersion = '1.12'
111+
}
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fr.minecraftforgefrance.common;
22

33
import java.net.URL;
4+
import java.net.URLEncoder;
45
import java.util.List;
56

67
import javax.xml.parsers.DocumentBuilder;
@@ -13,10 +14,10 @@
1314

1415
public class DownloadMod
1516
{
16-
private static final DownloadMod instance = new DownloadMod();
17-
18-
public int time = 0;
19-
17+
private static final DownloadMod instance = new DownloadMod();
18+
19+
public int time = 0;
20+
2021
public void getRemoteList(List<FileEntry> list, List<String> dir)
2122
{
2223
try
@@ -26,27 +27,29 @@ public void getRemoteList(List<FileEntry> list, List<String> dir)
2627
DocumentBuilder db = dbf.newDocumentBuilder();
2728
Document doc = db.parse(resourceUrl.openStream());
2829
NodeList nodeLst = doc.getElementsByTagName("Contents");
29-
30+
3031
long start = System.nanoTime();
3132
for(int i = 0; i < nodeLst.getLength(); i++)
3233
{
3334
Node node = nodeLst.item(i);
34-
35+
3536
if(node.getNodeType() == 1)
3637
{
3738
Element element = (Element)node;
3839
String key = element.getElementsByTagName("Key").item(0).getChildNodes().item(0).getNodeValue();
3940
long size = Long.parseLong(element.getElementsByTagName("Size").item(0).getChildNodes().item(0).getNodeValue());
4041
String md5 = element.getElementsByTagName("MD5").item(0).getChildNodes().item(0).getNodeValue();
41-
42+
4243
if(size > 0L)
4344
{
44-
String link = RemoteInfoReader.instance().getSyncUrl() + key;
45-
list.add(new FileEntry(new URL(link), md5, key, size));
45+
String name = key.substring(key.lastIndexOf("/") + 1);
46+
String path = key.substring(0, key.lastIndexOf("/") +1);
47+
String link = RemoteInfoReader.instance().getSyncUrl() + path + URLEncoder.encode(name, "UTF-8");
48+
list.add(new FileEntry(new URL(link), md5, key, size));
4649
}
4750
else if(key.split("/").length == 1)
4851
{
49-
dir.add(key.replace("/", ""));
52+
dir.add(key.replace("/", ""));
5053
}
5154
}
5255
}
@@ -56,12 +59,12 @@ else if(key.split("/").length == 1)
5659
}
5760
catch(Exception ex)
5861
{
59-
ex.printStackTrace();
62+
ex.printStackTrace();
6063
}
6164
}
62-
65+
6366
public static DownloadMod instance()
6467
{
65-
return instance;
68+
return instance;
6669
}
6770
}

src/main/java/fr/minecraftforgefrance/common/DownloadUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public static boolean downloadFile(final URL url, final File dest, final JProgre
4545

4646
try
4747
{
48-
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
49-
URL url2 = uri.toURL();
50-
URLConnection connection = url2.openConnection();
48+
URLConnection connection = url.openConnection();
5149

5250
int fileLength = connection.getContentLength();
5351
bar.setMaximum(fileLength);

0 commit comments

Comments
 (0)