core/includes/common.inc | 8 + core/modules/filter/filter.api.php | 28 +++ core/modules/filter/filter.module | 200 +++++++++++++++++++- .../lib/Drupal/filter/Tests/FilterAPITest.php | 143 ++++++++++++++ .../lib/Drupal/filter/Tests/FilterSecurityTest.php | 19 +- core/modules/php/php.module | 1 + 6 files changed, 396 insertions(+), 3 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index ff2fcb3..3c18589 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3741,6 +3741,9 @@ function drupal_region_class($region) { * - browsers: An array containing information specifying which browsers * should load the JavaScript item. See * drupal_pre_render_conditional_comments() for details. + * - attributes: An associative array of custom additional attributes for the + * rendered HTML element. Note that attributes resulting of other specified + * options cannot be overridden. * * @return * The current array of JavaScript files, settings, and in-line code, @@ -4072,6 +4075,11 @@ function drupal_pre_render_scripts($elements) { } } + // Apply custom HTML element attributes, if any have been specified. + if (!empty($item['attributes'])) { + $element['#attributes'] += $item['attributes']; + } + $elements[] = $element; } } diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php index f11a528..e4d032d 100644 --- a/core/modules/filter/filter.api.php +++ b/core/modules/filter/filter.api.php @@ -59,6 +59,9 @@ * - settings callback: The name of a function that returns configuration * form elements for the filter. See hook_filter_FILTER_settings() for * details. + * - allowed tags callback: The name of a function that returns an array of + * tags that are allowed by this filter. This is only necessary for filters + * that strip away other tags. * - default settings: An associative array containing default settings for * the filter, to be applied when the filter has not been configured yet. * - prepare callback: The name of a function that escapes the content before @@ -84,6 +87,7 @@ function hook_filter_info() { 'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'), 'process callback' => '_filter_html', 'settings callback' => '_filter_html_settings', + 'allowed tags callback' => '_filter_html_allowed_tags', 'default settings' => array( 'allowed_html' => '