From debd4f1aeaa8ac9a522b0288e7b5faa618902124 Mon Sep 17 00:00:00 2001 From: heavyrain2012 Date: Thu, 5 Aug 2021 15:44:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/config/ConfigurationParser.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/broker/src/main/java/io/moquette/server/config/ConfigurationParser.java b/broker/src/main/java/io/moquette/server/config/ConfigurationParser.java index eaafebd6..502f88b3 100644 --- a/broker/src/main/java/io/moquette/server/config/ConfigurationParser.java +++ b/broker/src/main/java/io/moquette/server/config/ConfigurationParser.java @@ -84,34 +84,37 @@ class ConfigurationParser { String line; try { while ((line = br.readLine()) != null) { + line = line.trim(); int commentMarker = line.indexOf('#'); if (commentMarker != -1) { if (commentMarker == 0) { // skip its a comment continue; } else { - // it's a malformed comment - throw new ParseException(line, commentMarker); + String[] ss = line.split(" "); + if(ss.length != 2) { + throw new ParseException(line, commentMarker); + } } } else { if (line.isEmpty() || line.matches("^\\s*$")) { // skip it's a black line continue; } - - // split till the first space - int delimiterIdx = line.indexOf(' '); - String key; - String value = ""; - if (delimiterIdx > 0) { - key = line.substring(0, delimiterIdx).trim(); - value = line.substring(delimiterIdx).trim(); - } else { - key = line.trim(); - } - - m_properties.put(key, value); } + + // split till the first space + int delimiterIdx = line.indexOf(' '); + String key; + String value = ""; + if (delimiterIdx > 0) { + key = line.substring(0, delimiterIdx).trim(); + value = line.substring(delimiterIdx).trim(); + } else { + key = line.trim(); + } + + m_properties.put(key, value); } } catch (IOException ex) { throw new ParseException("Failed to read", 1);