mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-15 20:51:21 +01:00
Improved name encoding of export filenames
This commit is contained in:
parent
5ef3c64dc3
commit
e04633d916
@ -32,6 +32,7 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public class JSONExport extends SpecificExport {
|
|||||||
try {
|
try {
|
||||||
File htmlLocation = getPlayerFolder();
|
File htmlLocation = getPlayerFolder();
|
||||||
htmlLocation.mkdirs();
|
htmlLocation.mkdirs();
|
||||||
File exportFile = new File(htmlLocation, playerName.replace(" ", "%20").replace(".", "%2E") + ".json");
|
File exportFile = new File(htmlLocation, URLEncoder.encode(playerName, "UTF-8") + ".json");
|
||||||
|
|
||||||
export(exportFile, Collections.singletonList(json));
|
export(exportFile, Collections.singletonList(json));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -94,7 +95,7 @@ public class JSONExport extends SpecificExport {
|
|||||||
try {
|
try {
|
||||||
File htmlLocation = getServerFolder();
|
File htmlLocation = getServerFolder();
|
||||||
htmlLocation.mkdirs();
|
htmlLocation.mkdirs();
|
||||||
File exportFile = new File(htmlLocation, serverName.replace(" ", "%20").replace(".", "%2E") + ".json");
|
File exportFile = new File(htmlLocation, URLEncoder.encode(serverName, "UTF-8") + ".json");
|
||||||
|
|
||||||
export(exportFile, Collections.singletonList(json));
|
export(exportFile, Collections.singletonList(json));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plugin.api.Check;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -92,7 +93,7 @@ public abstract class SpecificExport {
|
|||||||
protected void exportPlayerPage(String playerName, String html) throws IOException {
|
protected void exportPlayerPage(String playerName, String html) throws IOException {
|
||||||
List<String> lines = Arrays.asList(html.split("\n"));
|
List<String> lines = Arrays.asList(html.split("\n"));
|
||||||
|
|
||||||
File htmlLocation = new File(getPlayerFolder(), playerName.replace(" ", "%20").replace(".", "%2E"));
|
File htmlLocation = new File(getPlayerFolder(), URLEncoder.encode(playerName, "UTF-8").replace(".", "%2E"));
|
||||||
htmlLocation.mkdirs();
|
htmlLocation.mkdirs();
|
||||||
File exportFile = new File(htmlLocation, "index.html");
|
File exportFile = new File(htmlLocation, "index.html");
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ public abstract class SpecificExport {
|
|||||||
if (serverUUID.equals(serverInfo.getServerUUID())) {
|
if (serverUUID.equals(serverInfo.getServerUUID())) {
|
||||||
htmlLocation = new File(getFolder(), "network");
|
htmlLocation = new File(getFolder(), "network");
|
||||||
} else {
|
} else {
|
||||||
htmlLocation = new File(getServerFolder(), serverName.replace(" ", "%20").replace(".", "%2E"));
|
htmlLocation = new File(getServerFolder(), URLEncoder.encode(serverName, "UTF-8").replace(".", "%2E"));
|
||||||
html = html.replace("../", "../../");
|
html = html.replace("../", "../../");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user