HTML::comment

Description

Queries, removes HTML comment or appends/prepends it by a string.

Syntax

HTML::comment
HTML::comment append <string>
HTML::comment prepend <string>
HTML::comment remove

HTML::comment

  • Return the entire HTML comment, including the opening and the closing delimiter.

HTML::comment append <string>

  • Insert a string after the closing delimiter of the HTML comment; when multiple appends are issued, the inserted strings are ordered according to the sequence of the append commands as they are issued for the given comment.

HTML::comment prepend <string>

  • Insert a string before the opening delimiter of the HTML comment; when multiple prepends are issued, the inserted strings are ordered according to the sequence of the prepend commands as they are issued for the given comment.

HTML::comment remove

  • Remove the HTML comment.

Examples

  • Removing HTML comments:

when HTTP_RESPONSE {
  HTML::enable
}
when HTML_COMMENT_MATCHED {
  if { ! ( [HTML::comment] contains "\[" ) } {
    HTML::comment remove
  }
}

  • The httpcompression profile, which strips off the Accept-Encoding header from the HTTP request headers so that the backend server does not respond to BIG-IP with compressed content, can be used to allow the HTML filter to see the HTTP body (containing HTML) uncompressed. Alternatively, using an iRule command such as HTTP::header remove “Accept-Encoding” in the HTTP_REQUEST event will accomplishes the same thing.
  • The HTML::enable command running in HTTP_RESPONSE enables HTML processing for every transaction in a flow. Adding some iRules to selectively enable (or disable) HTML based on the Content-Type header in HTTP response helps to improve performance.
  • Internet Explorer-specific conditional comments, which contain brackets, should not be removed, and the iRule recognizes these as HTML comments.
  • HTML comments may often appear inside of Javascript or CSS as a way to maintain compatibility with earlier versions of HTML browsers that do not support Javascript or CSS. Modern HTML browsers recognize that these are not HTML comments and should not be stripped. Using “process:content” as an action inside of the script and the style tags, makes the HTML filter ignore Javascript and CSS.

  • append/prepend examples:
    when HTML_COMMENT_MATCHED {
    
    HTML::comment append "some_string"
    
    }
    


when HTML_COMMENT_MATCHED {
  HTML::comment prepend "some_string"
}