@@ -188,13 +188,12 @@ public class GaclParser {
188188 createDirective ("denySubscribe" , DenySubscribeAclRule ::new ));
189189
190190 public List <AclRule > parse (String input ) {
191- String cleaned = stripComments (input );
192191 try {
193192 return DIRECTIVE
194193 .atLeastOnce ()
195- .parseSkipping (WHITESPACE , cleaned );
194+ .parseSkipping (WHITESPACE , input );
196195 } catch (Parser .ParseException e ) {
197- throw new AclConfigurationException ("Syntax error at %s" .formatted (toLineColumn (cleaned , e .getSourceIndex ())));
196+ throw new AclConfigurationException ("Syntax error at %s" .formatted (toLineColumn (input , e .getSourceIndex ())));
198197 }
199198 }
200199
@@ -217,53 +216,6 @@ private MqttUserCondition toUserCondition(String identityType, ValueMatcher<Stri
217216 };
218217 }
219218
220- private String stripComments (String input ) {
221- StringBuilder sb = new StringBuilder (input .length ());
222- int i = 0 ;
223- boolean inString = false ;
224- char stringDelimiter = '\0' ;
225- while (i < input .length ()) {
226- char c = input .charAt (i );
227- if (inString ) {
228- sb .append (c );
229- if (c == '\\' && i + 1 < input .length ()) {
230- i ++;
231- sb .append (input .charAt (i ));
232- } else if (c == stringDelimiter ) {
233- inString = false ;
234- }
235- i ++;
236- } else if (c == '"' || c == '\'' ) {
237- inString = true ;
238- stringDelimiter = c ;
239- sb .append (c );
240- i ++;
241- } else if (i + 1 < input .length () && c == '/' && input .charAt (i + 1 ) == '/' ) {
242- while (i < input .length () && input .charAt (i ) != '\n' ) {
243- i ++;
244- }
245- } else if (i + 1 < input .length () && c == '/' && input .charAt (i + 1 ) == '*' ) {
246- i += 2 ;
247- boolean closed = false ;
248- while (i + 1 < input .length ()) {
249- if (input .charAt (i ) == '*' && input .charAt (i + 1 ) == '/' ) {
250- i += 2 ;
251- closed = true ;
252- break ;
253- }
254- i ++;
255- }
256- if (!closed ) {
257- throw new AclConfigurationException ("Unterminated block comment" );
258- }
259- } else {
260- sb .append (c );
261- i ++;
262- }
263- }
264- return sb .toString ();
265- }
266-
267219 private String toLineColumn (String input , int index ) {
268220 int line = 1 ;
269221 int col = 1 ;
0 commit comments