diff --git a/wysiwyg_filter.inc b/wysiwyg_filter.inc index 18f68c9..385a976 100644 --- a/wysiwyg_filter.inc +++ b/wysiwyg_filter.inc @@ -194,9 +194,9 @@ function wysiwyg_filter_parse_valid_elements($valid_elements) { } } - // Obtain list of element names/synonyms (separated by /). - // Consider synonyms as different elements with same exact attributes. - foreach ($elements as $element) { + // Get the element name. + // If it has synonyms (separated by /), these are handled below. + $element = array_shift($elements); if ($element == '@') { // These attributes should be enabled for all elements. foreach ($attributes as $attribute => $attribute_options) { @@ -233,6 +233,10 @@ function wysiwyg_filter_parse_valid_elements($valid_elements) { } } } + // For each synonym, instead of an attribute list, provide the name of the + // element it is converted to. + foreach ($elements as $synonym) { + $parsed_elements[$synonym] = $element; } } } diff --git a/wysiwyg_filter.pages.inc b/wysiwyg_filter.pages.inc index 40b5e3e..1333ce5 100644 --- a/wysiwyg_filter.pages.inc +++ b/wysiwyg_filter.pages.inc @@ -104,6 +104,11 @@ function _wysiwyg_filter_xss_split($m, $store = FALSE) { $attrlist = &$matches[3]; $comment = &$matches[4]; + // Convert synonyms to the element they get converted to. + if (!empty($filter_options['valid_elements'][$elem]) && is_string($filter_options['valid_elements'][$elem])) { + $elem = $filter_options['valid_elements'][$elem]; + } + if (!empty($comment)) { // Allow or disallow HTML comments. return (!empty($filter_options['allow_comments']) ? $comment : ''); @@ -263,7 +268,8 @@ function _wysiwyg_filter_xss_attributes($attr, $element = '') { } // The attribute list ends with a valueless attribute like "selected". - if ($mode == 1 && !$skip) { + // is_array() ensures this isn't run for synonyms. + if ($mode == 1 && !$skip && is_array($attrarr[$attrname])) { $attrarr[$attrname] = array(); }