Class Attribute

java.lang.Object
org.owasp.validator.html.model.Attribute

public class Attribute extends Object
A model for HTML attributes and the "rules" they must follow (either literals or regular expressions) in order to be considered valid.
Author:
Arshan Dabirsiaghi, Kristian Rosenvold
  • Constructor Details

  • Method Details

    • matchesAllowedExpression

      public boolean matchesAllowedExpression(String value)
    • containsAllowedValue

      public boolean containsAllowedValue(String valueInLowerCase)
    • getName

      public String getName()
    • getOnInvalid

      public String getOnInvalid()
      Returns:
      The onInvalid value a tag could have, from the list of "filterTag", "removeTag" and "removeAttribute"
    • mutate

      public Attribute mutate(String onInvalid, String description)
    • matcherRegEx

      public String matcherRegEx(boolean hasNext)
    • mergeRelValuesInAnchor

      public static String mergeRelValuesInAnchor(boolean addNofollow, boolean addNoopenerAndNoreferrer, String currentRelValue)
      This method takes the current rel attribute values and, depending on which ones to add, appends the corresponding values if they are not already present. It is meant to be used with anchor tags.
      Parameters:
      addNofollow - Specifies if "nofollow" value should be added in case it is not present.
      addNoopenerAndNoreferrer - Specifies if "noopener noreferrer" value should be added in case it is not present.
      currentRelValue - Current rel attribute value, it will be merged with the values specified from the previous parameters.
      Returns:
      The new rel attribute value to replace in an anchor tag.