Skip to content

Commit

Permalink
fix last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robin4002 committed Sep 24, 2015
1 parent 7a45307 commit fb70b98
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
compile 'com.google.guava:guava:14.0'
compile 'org.tukaani:xz:1.3'
compile 'net.minecraft:launchwrapper:1.9'
compile 'utybo:minkj:1.0'
compile 'utybo:minkj:1.0'
}

task fatJar(type: Jar, dependsOn: jar) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle~
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repositories {

group = 'net.minecraftforgefrance'
archivesBaseName = 'installer'
version = '1.0.8'
version = '1.0.9'
targetCompatibility = '1.6'
sourceCompatibility = '1.6'

Expand Down
36 changes: 33 additions & 3 deletions src/main/java/fr/minecraftforgefrance/common/DownloadMod.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.minecraftforgefrance.common;

import java.net.URL;
import java.net.URLEncoder;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -43,8 +42,8 @@ public void getRemoteList(List<FileEntry> list, List<String> dir)
if(size > 0L)
{
String name = key.substring(key.lastIndexOf("/") + 1);
String path = key.substring(0, key.lastIndexOf("/") +1);
String link = RemoteInfoReader.instance().getSyncUrl() + path + URLEncoder.encode(name, "UTF-8");
String path = key.substring(0, key.lastIndexOf("/") + 1);
String link = RemoteInfoReader.instance().getSyncUrl() + path + escapeURIPathParam(name);
list.add(new FileEntry(new URL(link), md5, key, size));
}
else if(key.split("/").length == 1)
Expand All @@ -67,4 +66,35 @@ public static DownloadMod instance()
{
return instance;
}

public static String escapeURIPathParam(String input)
{
StringBuilder resultStr = new StringBuilder();
for(char ch : input.toCharArray())
{
if(isUnsafe(ch))
{
resultStr.append('%');
resultStr.append(toHex(ch / 16));
resultStr.append(toHex(ch % 16));
}
else
{
resultStr.append(ch);
}
}
return resultStr.toString();
}

private static char toHex(int ch)
{
return (char)(ch < 10 ? '0' + ch : 'A' + ch - 10);
}

private static boolean isUnsafe(char ch)
{
if(ch > 128 || ch < 0)
return true;
return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/installer/local_info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"remoteUrl": "http://dl.mcnanotech.fr/FFMT/installer/demo/remote_info.json"
"remoteUrl": "http://stratiznetwork.olympe.in/Installeur/remote_info.json"
}

0 comments on commit fb70b98

Please sign in to comment.