[#2341] Sanitize groupnames

This commit is contained in:
SiboVG 2023-09-20 13:27:58 +02:00
parent 19854154b4
commit d36b5d3e9d

View File

@ -154,6 +154,7 @@ public class OBJExporterFactory {
// Component exporting
String groupName = idx + "_" + component.getName();
groupName = sanitizeGroupName(groupName);
handleComponent(obj, this.configuration, this.options.getTransformer(), component, groupName,
materials.get(obj), this.options.getLOD(), options, warnings);
@ -293,6 +294,20 @@ public class OBJExporterFactory {
return sortedComponents;
}
/**
* Sanitize the group name by replacing illegal characters with underscores.
* @param groupName the group name to sanitize
* @return the sanitized group name
*/
private static String sanitizeGroupName(String groupName) {
Character c = FileUtils.getIllegalFilenameChar(groupName);
while (c != null) {
groupName = groupName.replace(c, '_');
c = FileUtils.getIllegalFilenameChar(groupName);
}
return groupName;
}
private void addChildComponentToList(RocketComponent parent, Set<RocketComponent> components, Set<RocketComponent> sortedComponents) {
for (RocketComponent child : parent.getChildren()) {
if (components.contains(child)) {