Fix (and no longer be symlink safe again )-;)

This commit is contained in:
skippyall
2026-05-22 20:43:06 +02:00
parent 017ca40e3e
commit 12c2dd5b22
6 changed files with 14 additions and 14 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
}
group = 'io.github.skippyall'
version = '1.0-SNAPSHOT'
version = '1.0.0'
subprojects {
repositories {
@@ -1,6 +1,7 @@
package io.github.skippyall.ruler;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
@@ -12,10 +13,12 @@ public class FileUtils {
public static String removeExtension(String path) {
if(path.contains(".")) {
return path.substring(0, path.lastIndexOf('.'));
} else {
return path;
int index = path.lastIndexOf('.');
if(index > path.lastIndexOf(FileSystems.getDefault().getSeparator())) {
return path.substring(0, index);
}
}
return path;
}
public static String getExtension(Path path) {
@@ -25,7 +25,7 @@ public class ConfigLoader {
}
RuleConfig config = null;
Path configPath = FileUtils.append(fileWithoutExtension, ".config.json");
String rulePath = RuleUtils.getRulePathFromWithoutExtension(fileWithoutExtension.toString());
String rulePath = RuleUtils.getRulePath(fileWithoutExtension);
if(Files.isRegularFile(configPath)) {
try {
config = RuleConfig.loadFromJson(JsonParser.parseReader(Files.newBufferedReader(configPath)), rulePath);
@@ -35,7 +35,8 @@ public class RuleUtils {
}
public static boolean isValidRulePath(String path) {
return path.matches("([A-Za-z0-9\\-_.]+)") &&
return path.isEmpty() ||
path.matches("([A-Za-z0-9\\-_.]+)") &&
Arrays.stream(path.split("\\.")).noneMatch(String::isEmpty);
}
@@ -46,11 +47,7 @@ public class RuleUtils {
}
public static boolean isInDirectory(Path path) {
try {
return path.toRealPath().startsWith(getRoot());
} catch (IOException e) {
return false;
}
return path.toAbsolutePath().startsWith(getRoot());
}
public static void checkDirectory(Path path) throws InvalidRulePathException {
+3 -2
View File
@@ -4,7 +4,7 @@ plugins {
id 'com.gradleup.shadow' version '9.4.1'
}
version = project.mod_version
version = project.getParent().version
group = project.maven_group
base {
@@ -76,6 +76,7 @@ java {
}
jar {
archiveClassifier = 'dev'
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
@@ -83,7 +84,7 @@ jar {
shadowJar {
configurations = [project.configurations.shadowBundle]
archiveClassifier = 'dev-shadow'
archiveClassifier = ''
relocate("de.themoep.minedown.adventure", "io.github.skippyall.minedown")
}
-1
View File
@@ -8,7 +8,6 @@ org.gradle.jvmargs=-Xmx1G
loom_version=1.16-SNAPSHOT
# Mod Properties
mod_version = 1.0.0
maven_group = io.github.skippyall
archives_base_name = ruler-fabric