Problem/Motivation

When validating a filter format's edit page, entity_embed_filter_format_edit_form_validate() fails to account for a scenario where 'filter_html' is disabled.

The validation function should not be concerned with HTML restrictions of a disabled filter. The result is that a site builder cannot save the filter format.

Steps to reproduce

  1. Create a filter format with 'filter_html' disabled.
  2. Add an Entity Embed button to the WYSIWYG.
  3. Save
  4. Observe the following error:'The %embed button requires <drupal-entity> among the allowed HTML tags.'

Proposed resolution

Check if 'filter_html' filter is enabled before proceeding with validation.

Remaining tasks

Submit patch
Update tests once initial review is complete

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

Comments

Chris Burge created an issue. See original summary.

chris burge’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new813 bytes
oknate’s picture

comment removed see below

oknate’s picture

I can recreate it with the steps in the issue summary:

  1. Create filter format
  2. Drag an entity embed button to toolbar
  3. Check 'Limit allowed HTML tags and correct faulty HTML'
  4. Check 'Display embedded entities'
  5. Save
  6. Reopen form
  7. Remove <drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-display-settings data-align data-caption data-embed-button data-langcode alt title> from allowed tags
  8. Uncheck 'Limit allowed HTML tags and correct faulty HTML'
  9. Save

You get an error "The %embed button requires among the allowed HTML tags." even though html_filter has been disabled.

chris burge’s picture

@oknate - Thanks for clarifying the steps to reproduce.

oknate’s picture

Status: Needs review » Needs work

When I use the steps in #4 with the patch applied I get this:

Notice: Undefined index: drupal-entity in entity_embed_filter_format_edit_form_validate() (line 183 of modules/contrib/entity_embed/entity_embed.module).
entity_embed_filter_format_edit_form_validate(Array, Object)

Thanks for raising this issue! The patch needs work though.

chris burge’s picture

Status: Needs work » Closed (duplicate)
chris burge’s picture

Assigned: chris burge » Unassigned