_filter_url_escape_comments($match, $escape = NULL)
Escapes the contents of HTML comments.
Callback for preg_replace_callback() within _filter_url().
Parameters
array $match: An array containing matches to replace from preg_replace_callback(), whereas $match[1] is expected to contain the content to be filtered.
bool|null $escape: (optional) A Boolean indicating whether to escape (TRUE) or unescape comments (FALSE). Defaults to NULL, indicating neither. If TRUE, statically cached $comments are reset.
Related topics
- Standard filters
- Filters implemented by the Filter module.
File
- core/modules/filter/filter.module, line 645
- Framework for handling the filtering of content.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | function _filter_url_escape_comments( $match , $escape = NULL) { static $mode , $comments = array (); if (isset( $escape )) { $mode = $escape ; if ( $escape ) { $comments = array (); } return ; } // Replace all HTML comments with a '<!-- [hash] -->' placeholder. if ( $mode ) { $content = $match [1]; $hash = hash( 'sha256' , $content ); $comments [ $hash ] = $content ; return "<!-- $hash -->" ; } // Or replace placeholders with actual comment contents. else { $hash = $match [1]; $hash = trim( $hash ); $content = $comments [ $hash ]; return "<!--$content-->" ; } } |
Please login to continue.