Limit names to 100 bytes

This commit is contained in:
Marko Topolnik
2024-01-05 23:03:28 +01:00
committed by Gunnar Morling
parent a094d07925
commit e09cb7deea
3 changed files with 50 additions and 33 deletions

View File

@@ -21,6 +21,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.concurrent.ThreadLocalRandom;
@@ -113,6 +114,9 @@ public class CreateMeasurements3 {
while (names.contains(name)) {
name = name.substring(1) + readNonSpace(nameSource);
}
while (name.getBytes(StandardCharsets.UTF_8).length > 100) {
name = name.substring(0, name.length() - 1);
}
if (name.indexOf(';') != -1) {
throw new Exception("Station name contains a semicolon!");
}