_filter_url_escape_comments
function _filter_url_escape_comments
_filter_url_escape_comments($match, $escape = NULL)
Escapes the contents of HTML comments.
Callback for preg_replace_callback() within _filter_url().
Parameters
$match: An array containing matches to replace from preg_replace_callback(), whereas $match[1] is expected to contain the content to be filtered.
$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
File
- modules/filter/filter.module, line 1627
- Framework for handling the filtering of content.
Code
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 coments with a '<!-- [hash] -->' placeholder. if ($mode) { $content = $match[1]; $hash = md5($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-->"; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!filter!filter.module/function/_filter_url_escape_comments/7.x