Fixed BOM case in check of properties files.

This commit is contained in:
Christian P. MOMON 2021-10-24 13:22:09 +02:00
parent 8af034256d
commit 1ec26ffec8

View file

@ -36,6 +36,8 @@ import fr.devinsy.strings.StringsUtils;
public class PropertyChecker
{
public static final String ALL = "^.*$";
public static final String BOM = "\ufeff";
public static final String COMMENT = "^#.*$";
public static final String STRING = "^.+$";
public static final String DATETIME = "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}([\\.,]\\d+)?)?([+-]\\d\\d:\\d\\d)?";
public static final String DATE = "^(\\d{4}-\\d{2}-\\d{2}|\\d{2}/\\d{2}/\\d{4}|\\d{2}/\\d{4})";
@ -227,6 +229,13 @@ public class PropertyChecker
result = new PropertyChecks();
//
if ((lines != null) && (!lines.isEmpty()) && (lines.get(0).startsWith(BOM)))
{
String line = lines.get(0).substring(1);
lines.set(0, line);
}
//
PropertyRules requiredRules = rules.getMandatories();
requiredRules.addAll(rules.getWished());
@ -281,7 +290,7 @@ public class PropertyChecker
check = new PropertyCheck(lineIndex, "", Status.OK);
check.setComment("OK");
}
else if ((StringUtils.isEmpty(line)) || (line.matches("^#.*$")))
else if ((StringUtils.isEmpty(line)) || (line.matches(COMMENT)))
{
check = new PropertyCheck(lineIndex, line, Status.OK);
check.setComment("OK");