Class EscapeTool


  • @ThreadSafe
    public class EscapeTool
    extends java.lang.Object
    An extremely simple wrapper around various escape utils to perform URL and HTML encoding within the reports. This class was created to simplify the velocity configuration and avoid using the "built-in" escape tool.
    Author:
    Jeremy Long
    • Constructor Summary

      Constructors 
      Constructor Description
      EscapeTool()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String csv​(java.lang.String text)
      Formats text for CSV format.
      java.lang.String csvCpeConfidence​(java.util.Set<Identifier> ids)
      Takes a set of Identifiers, filters them to just CPEs, and formats them for confidence display in a CSV.
      java.lang.String csvIdentifiers​(java.util.Set<Identifier> ids)
      Takes a set of Identifiers, filters them to none CPE, and formats them for display in a CSV.
      java.lang.String html​(java.lang.String text)
      HTML Encodes the provided text.
      java.lang.String javascript​(java.lang.String text)
      JavaScript encodes the provided text.
      java.lang.String json​(java.lang.String text)
      JSON Encodes the provided text.
      java.lang.String url​(java.lang.String text)
      URL Encodes the provided text.
      java.lang.String xml​(java.lang.String text)
      XML Encodes the provided text.
      • Methods inherited from class java.lang.Object

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

      • EscapeTool

        public EscapeTool()
    • Method Detail

      • url

        public java.lang.String url​(java.lang.String text)
        URL Encodes the provided text.
        Parameters:
        text - the text to encode
        Returns:
        the URL encoded text
      • html

        public java.lang.String html​(java.lang.String text)
        HTML Encodes the provided text.
        Parameters:
        text - the text to encode
        Returns:
        the HTML encoded text
      • xml

        public java.lang.String xml​(java.lang.String text)
        XML Encodes the provided text.
        Parameters:
        text - the text to encode
        Returns:
        the XML encoded text
      • json

        public java.lang.String json​(java.lang.String text)
        JSON Encodes the provided text.
        Parameters:
        text - the text to encode
        Returns:
        the JSON encoded text
      • javascript

        public java.lang.String javascript​(java.lang.String text)
        JavaScript encodes the provided text.
        Parameters:
        text - the text to encode
        Returns:
        the JavaScript encoded text
      • csv

        public java.lang.String csv​(java.lang.String text)
        Formats text for CSV format. This includes trimming whitespace, replace line breaks with spaces, and if necessary quotes the text and/or escapes contained quotes.
        Parameters:
        text - the text to escape and quote
        Returns:
        the escaped and quoted text
      • csvIdentifiers

        public java.lang.String csvIdentifiers​(java.util.Set<Identifier> ids)
        Takes a set of Identifiers, filters them to none CPE, and formats them for display in a CSV.
        Parameters:
        ids - the set of identifiers
        Returns:
        the formatted list of none CPE identifiers
      • csvCpeConfidence

        public java.lang.String csvCpeConfidence​(java.util.Set<Identifier> ids)
        Takes a set of Identifiers, filters them to just CPEs, and formats them for confidence display in a CSV.
        Parameters:
        ids - the set of identifiers
        Returns:
        the formatted list of confidence