Class InvalidURIRule

java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.InvalidURIRule

public class InvalidURIRule extends Rule

Rule that protects against invalid unicode characters in URLs, returning a configurable status code with body message.

The logic is as follows:

  • if a decoded URI character is an iso control character, apply the rule
  • if no Character.UnicodeBlock is found for a decoded URI character, apply the rule
  • if a decoded URI character is in UnicodeBlock.SPECIALS, apply the rule
  • Constructor Details

    • InvalidURIRule

      public InvalidURIRule()
  • Method Details

    • isTerminating

      public boolean isTerminating()
      Overrides:
      isTerminating in class Rule
      Returns:
      whether rules after this one are not invoked
    • getCode

      public int getCode()
    • setCode

      public void setCode(int code)
      Set the response code.
      Parameters:
      code - the response code
    • getMessage

      public String getMessage()
    • setMessage

      public void setMessage(String message)

      Sets the message for the response body (if the response code may have a body).

      Parameters:
      message - the response message
    • matchAndApply

      public Rule.Handler matchAndApply(Rule.Handler input) throws IOException
      Description copied from class: Rule

      Tests whether the given input Handler (which wraps a Request) matches the rule, and if so returns an output Handler that applies the rule logic.

      If the input does not match, null is returned.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Handler that wraps the Request
      Returns:
      an output Handler that wraps the input Handler, or null if the rule does not match
      Throws:
      IOException - if applying the rule fails
    • isValidChar

      protected boolean isValidChar(int codepoint)
    • toString

      public String toString()
      Overrides:
      toString in class Rule