function _filter_url_escape_comments
Same name in other branches
- 9 core/modules/filter/filter.module \_filter_url_escape_comments()
- 8.9.x core/modules/filter/filter.module \_filter_url_escape_comments()
- 10 core/modules/filter/filter.module \_filter_url_escape_comments()
- 11.x core/modules/filter/filter.module \_filter_url_escape_comments()
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
1 call to _filter_url_escape_comments()
- _filter_url in modules/
filter/ filter.module - Implements callback_filter_process().
1 string reference to '_filter_url_escape_comments'
- _filter_url in modules/
filter/ filter.module - Implements callback_filter_process().
File
-
modules/
filter/ filter.module, line 1629
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 = hash('sha256', $content);
$comments[$hash] = $content;
return "<!-- {$hash} -->";
}
else {
$hash = $match[1];
$hash = trim($hash);
$content = $comments[$hash];
return "<!--{$content}-->";
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.