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:
      when true, rules after this one are not invoked
    • getCode

      public int getCode()
    • setCode

      public void setCode(int 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 Request should apply, and if so the rule logic is triggered.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Request and Handler
      Returns:
      the possibly wrapped Request and Handler, or null if the rule did not match
      Throws:
      IOException - if applying the rule failed
    • isValidChar

      protected boolean isValidChar(int codepoint)
    • toString

      public String toString()
      Description copied from class: Rule
      Returns the handling and terminating flag values.
      Overrides:
      toString in class Rule