Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static AuthorizationsCollector parse(Reader reader) throws ParseException
Pattern commentLine = Pattern.compile("^#.*"); // As spec, comment lines should start with '#'
Pattern invalidCommentLine = Pattern.compile("^\\s*#.*");
// This pattern has a dependency on filtering `commentLine`.
Pattern endLineComment = Pattern.compile("^([\\w\\s\\/\\+]+#?)(\\s*#.*)$");
Pattern endLineComment = Pattern.compile("^(\\S+\\s+(\\S+\\s+)?[^\\s#]+(?:/[+#])?)(?:\\s+#.*)?$");
Matcher endLineCommentMatcher;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public void testParseValidEndLineComment() throws ParseException {
assertTrue(authorizations.canWrite(new Topic("/weather/italy/anemometer"), "", ""));
}

@Test
public void testParseEndWithPoundTopicWithoutEndLineComment() throws ParseException {
Reader conf = new StringReader("topic /weather/italy/#");
AuthorizationsCollector authorizations = ACLFileParser.parse(conf);

// Verify
assertTrue(authorizations.canRead(new Topic("/weather/italy/#"), "", ""));
assertTrue(authorizations.canWrite(new Topic("/weather/italy/#"), "", ""));
}

@Test
public void testParseValidPoundTopicWithEndLineComment() throws ParseException {
Reader conf = new StringReader("topic /weather/italy/anemometer/# #simple comment");
Expand Down