Class ValidUrlRule


  • public class ValidUrlRule
    extends Rule
    This rule can be used to protect against invalid unicode characters in a url making it into applications.

    The logic is as follows.

    • if decoded uri character is an iso control character return code/reason
    • if no UnicodeBlock is found for character return code/reason
    • if character is in UnicodeBlock.SPECIALS return code/reason
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule

        Rule.ApplyURI
    • Constructor Summary

      Constructors 
      Constructor Description
      ValidUrlRule()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean isValidChar​(int codepoint)  
      java.lang.String matchAndApply​(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      This method calls tests the rule against the request/response pair and if the Rule applies, then the rule's action is triggered.
      void setCode​(java.lang.String code)
      Sets the response status code.
      void setReason​(java.lang.String reason)
      Sets the reason for the response status code.
      java.lang.String toString()
      Returns the handling and terminating flag values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ValidUrlRule

        public ValidUrlRule()
    • Method Detail

      • setCode

        public void setCode​(java.lang.String code)
        Sets the response status code.
        Parameters:
        code - response code
      • setReason

        public void setReason​(java.lang.String reason)
        Sets the reason for the response status code. Reasons will only reflect if the code value is greater or equal to 400.
        Parameters:
        reason - the reason
      • matchAndApply

        public java.lang.String matchAndApply​(java.lang.String target,
                                              javax.servlet.http.HttpServletRequest request,
                                              javax.servlet.http.HttpServletResponse response)
                                       throws java.io.IOException
        Description copied from class: Rule
        This method calls tests the rule against the request/response pair and if the Rule applies, then the rule's action is triggered.
        Specified by:
        matchAndApply in class Rule
        Parameters:
        target - The target of the request
        request - the request
        response - the response
        Returns:
        The new target if the rule has matched, else null
        Throws:
        java.io.IOException - if unable to match the rule
      • isValidChar

        protected boolean isValidChar​(int codepoint)
      • toString

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