Problem/Motivation
Helping out at #3358205: <span style> breaks 'Limit allowed HTML tags and correct faulty HTML' validation is what led me here.
In order for this filter to truly be a viable alternative to Drupal core's filter_html, this should also:
- Match the automatic loading of certain CKEditor 5 plugins whenever
filter_htmlis active for a text format ⇒ otherwise CKEditor 5 does not correctly match the filter - Match the automatic updating of the "Allowed HTML tags" setting whenever updating the CKEditor 5 configuration ⇒ otherwise configuring this filter is much more difficult (i.e. 100% manual)
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | b3401513.zip | 2.33 KB | brad.bulger |
| #3 | extended_html_filter fully integrated into CKEditor 5 1080p.mov | 34.98 MB | wim leers |
Issue fork extended_html_filter-3401513
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
wim leersI figured it'd be worth me spending 2 hours on making this nice to avoid more people from pulling their hair out:
Attached is a 1.5 minute screencast demonstrating:
extended_html_filterinstead offilter_htmlextended_html_filter, and disablefilter_htmlextended_html_filter.settingsis respectedP.S.: the only thing that's not yet implemented is ensuring that when
extended_html_filter.settingschanges, all rendered/filtered content have their caches wiped. That'd be a one-line addition to the filter, but it's such a rare operation that it was perhaps intentional?Comment #4
brad.bulger commentedThe core "Limit allowed HTML" filter is taking other plugins into account in the read-only list of allowed HTML that it generates. The "Extended HTML Filter" is not, at least not for me.
For example, in the Alignment plugin settings, I have all of the available alignments enabled: left, center, right, and justify. In the HTML tags allowed by "Limit allowed HTML", it includes alignment classes on the header tags:
<h2 class="text-align-left text-align-center text-align-right text-align-justify">etc. The tags for "Extended HTML" only include the "id" attribute for the header tags - except for<h2 id='jump-*'>which I don't recognize offhand.Comment #5
wim leers#4: I cannot reproduce any of that. 🤔 All symptoms you mention (thanks for describing them in such detail 👏) are consistent with not having cleared all caches. That's necessary after modifying the code like this. Could you do a
drush crand try again? 🙏Comment #6
brad.bulger commentedI wasn't using the issue fork code properly. I've moved to a vanilla Drupal 10 installation, with none of the other CKEditor modules I had installed in the first instance. I create a new text format, that uses CKEditor. The only buttons enabled are the default ones: Headings, bold, and italic. The only filter enabled is Extended HTML Filter. Now the "Allowed HTML tags" field of the Extended HTML filter settings is read-only, like the core Limit HTML filter. The tags enabled are
<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>. Trying to save this, I get an error:Comment #7
brad.bulger commentedI ended up having to change extended_html_filter.ckeditor5.yml to set the
<* style>element to match the styles I defined on the Extended HTML config page. Otherwise, it seems it wants that unrestricted style attribute and gives a validation error on the restricted style values from the plugin config.Comment #8
wim leersI cannot reproduce this either.
Can you please provide
Comment #9
quentin.le-delas commentedI'm reproduce the same issue as @brad.bulger.
Can you give a example of your extended_html_filter.ckeditor5.yml workarround ?
Comment #10
wim leers@Quentin.Le-Delas Please see #8. You too can help me reproduce this.
Comment #11
brad.bulger commentedI don't have the change to the ckeditor5.yml file around anymore, unfortunately. Our development is stuck in 9.5 for the moment, I don't think it's worth testing in this too much. I'm attaching config files for what it's worth.
Comment #12
brad.bulger commentedI spun up a test site on simplytest.me using 10.2 and extended_html_filter 1.0.x, applying the patch https://git.drupalcode.org/project/extended_html_filter/-/merge_requests... (that link should be good for 12 hours, then you will need to recreate the site)
This shows the first issue I described: if you enable the filter and try to save the format, you get an error that
<* style>is missing.Trying to enable Source editing and add
<* style>to the allowed tags fails:I can't attach config for this text format because I can't save these changes due to the error.
Comment #13
damienmckennaI'm able to reproduce the problem on a 10.2.1 site.
Comment #14
pasqualleEnabling the extended html filter (with this patch) on a multilingual site:
Comment #15
pasqualleThe problem is not related to multilingual.
The problem is that the
<* style>element is not part of the generated allowed html values.Comment #16
pasqualle#3226368: FilterHtml accepts <*> but does not support it, resulting in inaccurate ::getHtmlRestrictions() return value seems a bit related, but does not solve the
<* style>error.Comment #17
pasqualleOk, found the source of the problem.
<* style>vs<* style="width height">This check here:
FundamentalCompatibilityConstraintValidator.php#L158
creates a diff between
and shows the error
Comment #18
damienmckenna#3226368 does seem related.
Comment #19
zauravInstalled the extended_html_filter module and patched it with the MR !2 plaindiff but still getting the <* style> element missing message.
This is on clean install of drupal: 10.3.5
Comment #20
jvdkolk commentedGot the same error on Drupal 10.3.6...
In addition, I also got the following error after trying to save the text format with MR !2 in place:
Folks at https://www.drupal.org/project/shortcode had the same issue, and it was solved here https://www.drupal.org/project/shortcode/issues/3457731#comment-15681072
So I managed to solve the additional error by adding a file
config/schema/extended_html_filter.schema.yml
with contents