Skip to content

Commit

Permalink
Issue #11361 - UriCompliance.checkUriCompliance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Feb 23, 2024
1 parent 1e5aa10 commit b094034
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,25 @@ private static Set<Violation> copyOf(Set<Violation> violations)

public static String checkUriCompliance(UriCompliance compliance, HttpURI uri, ComplianceViolation.Listener listener)
{
for (UriCompliance.Violation violation : UriCompliance.Violation.values())
if (uri.hasViolations())
{
if (uri.hasViolation(violation) && (compliance == null || !compliance.allows(violation)))
return violation.getDescription();
else if (listener != null)
listener.onComplianceViolation(new ComplianceViolation.Event(compliance, violation, uri.toString()));
StringBuilder violations = null;
for (UriCompliance.Violation violation : UriCompliance.Violation.values())
{
if (uri.hasViolation(violation) && (compliance == null || !compliance.allows(violation)))
{
if (listener != null)
listener.onComplianceViolation(new ComplianceViolation.Event(compliance, violation, uri.toString()));

if (violations == null)
violations = new StringBuilder();
else
violations.append(", ");
violations.append(violation.getDescription());
}
}
if (violations != null)
return violations.toString();
}
return null;
}
Expand Down

0 comments on commit b094034

Please sign in to comment.