diff --git a/lib/externallib.php b/lib/externallib.php index 4469d2abbde..eb7d1c96144 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -743,6 +743,7 @@ function external_format_string($str, $contextid, $striplinks = true, $options = if (!$settings->get_raw()) { $context = context::instance_by_id($contextid); $options['context'] = $context; + $options['filter'] = $settings->get_filter(); $str = format_string($str, $striplinks, $options); } diff --git a/lib/weblib.php b/lib/weblib.php index 60b65d3bb49..634885bc1ff 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1354,6 +1354,9 @@ function format_string($string, $striplinks = true, $options = null) { } else if (is_numeric($options['context'])) { $options['context'] = context::instance_by_id($options['context']); } + if (!isset($options['filter'])) { + $options['filter'] = true; + } if (!$options['context']) { // We did not find any context? weird. @@ -1372,7 +1375,7 @@ function format_string($string, $striplinks = true, $options = null) { // Regular expression moved to its own method for easier unit testing. $string = replace_ampersands_not_followed_by_entity($string); - if (!empty($CFG->filterall)) { + if (!empty($CFG->filterall) && $options['filter']) { $filtermanager = filter_manager::instance(); $filtermanager->setup_page_for_filters($PAGE, $options['context']); // Setup global stuff filters may have. $string = $filtermanager->filter_string($string, $options['context']);