From 1ec26ffec885888bd102a3877c8100c607d3f347 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 24 Oct 2021 13:22:09 +0200 Subject: [PATCH] Fixed BOM case in check of properties files. --- .../devinsy/statoolinfos/checker/PropertyChecker.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java b/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java index 86df386..a183fcb 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java @@ -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");