Unverified Commit d56de091 authored by oknate's avatar oknate Committed by Dave Reid

Issue #3075245 by oknate: Fixed format config form validation should allow...

Issue #3075245 by oknate: Fixed format config form validation should allow wildcard attributes on the drupal-entity tag.
parent 29e5e9d9
......@@ -207,6 +207,20 @@ function entity_embed_filter_format_edit_form_validate($form, FormStateInterface
$missing_attributes = $required_attributes;
}
else {
// If any of the attributes on the drupal-entity tag use wildcards,
// iterate through and replace them with matching required
// attributes.
$wildcards = preg_grep('/\*/', array_keys($allowed['drupal-entity']));
if (!empty($wildcards)) {
foreach ($wildcards as $wildcard) {
$pattern = str_replace('*', '(.*)', $wildcard);
$matches = preg_grep('/' . $pattern . '/', $required_attributes);
foreach ($matches as $match) {
$allowed['drupal-entity'][$match] = 1;
}
unset($allowed['drupal-entity'][$wildcard]);
}
}
$missing_attributes = array_diff($required_attributes, array_keys($allowed['drupal-entity']));
}
......
......@@ -260,6 +260,12 @@ class ConfigurationUiTest extends EntityEmbedTestBase {
'allowed_html' => "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id> <drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-display-settings data-align data-embed-button data-langcode>",
'expected_error_message' => 'The <drupal-entity> tag in the allowed HTML tags is missing the following attributes: data-caption, alt, title.',
],
'Tests that wildcard for required attributes works' => [
'filters[filter_html][status]' => TRUE,
'filters[entity_embed][status]' => TRUE,
'allowed_html' => "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id> <drupal-entity data-* alt title>",
'expected_error_message' => FALSE,
],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment