Skip to content

Commit

Permalink
Bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Oct 25, 2022
1 parent 4c12b92 commit dd5d75b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/de/presti/ree6/language/LanguageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,23 @@ public static void initializeLanguages() {
* Called to download every Language file from the GitHub Repository.
*/
public static void downloadLanguages() {
File languagePath = Path.of("languages/").toFile();
if (!languagePath.exists()) {
if (languagePath.mkdirs()) {
log.info("Created the language folder!");
} else {
log.error("Couldn't create the language folder!");
}
}

try {
RequestUtility.requestJson(RequestUtility.Request.builder().url("https://api.github.com/repos/Ree6-Applications/Ree6/contents/languages").build()).getAsJsonArray().forEach(jsonElement -> {
String language = jsonElement.getAsJsonObject().get("name").getAsString().replace(".yml", "");
String download = jsonElement.getAsJsonObject().get("download_url").getAsString();

Path languageFile = Path.of("languages/", language + ".yml");

if (!languageFile.toAbsolutePath().startsWith(Path.of("languages/").toAbsolutePath())) {
if (!languageFile.toAbsolutePath().startsWith(languagePath.toPath().toAbsolutePath())) {
log.info("Ignoring Language download, since Path Traversal has been detected!");
return;
}
Expand Down

0 comments on commit dd5d75b

Please sign in to comment.