Skip to content

Commit

Permalink
Enable filtering out “Trailing slash” message without non-zero exit
Browse files Browse the repository at this point in the history
Fixes #1579

This change enables the “Trailing slash on void elements” message to be
filtered without causing an unexpected non-zero exit status if the
--Werror option is also used.

Otherwise, without this change, if the --Werror option is used and you
specify filtering of the “Trailing slash on void elements” message, then
the message will be filtered out — but the exit status will unexpectedly
be non-zero.
  • Loading branch information
sideshowbarker committed Apr 10, 2023
1 parent 0efb5e1 commit 470d919
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion htmlparser
20 changes: 10 additions & 10 deletions src/nu/validator/messages/MessageEmitterAdapter.java
Expand Up @@ -821,6 +821,16 @@ private void message(MessageType type, Exception message, String systemId,
int oneBasedLine, int oneBasedColumn, boolean exact, int[] start)
throws SAXException {
String msg = message.getMessage();
if (msg != null && ((filterPattern != null
&& filterPattern.matcher(msg).matches())
|| DEFAULT_FILTER_PATTERN.matcher(msg).matches())) {
if (type.getSuperType() == "error" && this.errors > 0) {
this.errors--;
} else if (type.getSubType() == "warning" && this.warnings > 0) {
this.warnings--;
}
return;
}
if (msg != null && msg.contains(
"Trailing slash on void elements has no effect")) {
if (type != MessageType.INFO) {
Expand All @@ -834,16 +844,6 @@ private void message(MessageType type, Exception message, String systemId,
true);
}
}
if (msg != null && ((filterPattern != null
&& filterPattern.matcher(msg).matches())
|| DEFAULT_FILTER_PATTERN.matcher(msg).matches())) {
if (type.getSuperType() == "error" && this.errors > 0) {
this.errors--;
} else if (type.getSubType() == "warning" && this.warnings > 0) {
this.warnings--;
}
return;
}
if (loggingOk
&& (type.getSuperType() == "error")
&& spec != EmptySpec.THE_INSTANCE
Expand Down

0 comments on commit 470d919

Please sign in to comment.