Skip to content
Snippets Groups Projects
Unverified Commit 266679c6 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3249263 by alexpott, andypost, Wim Leers: CKEditor 5 needs validate the...

Issue #3249263 by alexpott, andypost, Wim Leers: CKEditor 5 needs validate the filters in the correct order - CKEditor 5 tests fail locally

(cherry picked from commit dc51481d)
parent 6af996bb
No related branches found
No related tags found
21 merge requests!2496Issue #3222757 by lauriii, Wim Leers, nod_, rachel_norfolk, itmaybejj,...,!2366Issue #3285105 by Daniel Arend,!2304Issue #3258987: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() due to bug in PHP 8.1.0-8.1.5,!2148Issue #3270899: Remove Color module from core,!2136Issue #3227824: Move the linkset functionality from the decoupled menus contributed module to core's system module,!2071Issue #927570: Setting 403 or 404 handler to a page that redirects leads to endless loop,!1975Issue #3269749: losing query params from user to user/login redirect,!1959Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1481Issue #3252562: Allow functions that accept no arguments to be used as callable,!1443Issue #3075230: Provide menu link with disable option [Node Add Form],!1387Draft: Resolve #2511878 "Support enclosure field",!1321Issue #3239123: Refactor (if feasible) uses of the jQuery text function to use vanillaJS,!1282Issue #3227824: Add the decoupled menus module to core,!1269Issue #3239134: Refactor (if feasible) uses of the jQuery val function to use VanillaJS,!1262Issue #3239500: Add Array.includes polyfill to support IE11 and Opera Mini,!1229Issue #3225621: Use media query event listener instead of a listener on the resize event,!1159Convert dblog entries into entities,!799Issue #3214332: Preview content is broken in Claro.,!776Resolve #85494 "Use email verification 9.3.x",!558Resolve #3020422 "Toolbar style update",!231Issue #2671162: summary text wysiwyg patch working fine on 9.2.0-dev
......@@ -84,7 +84,6 @@ private function checkNoMarkupFilters(FilterFormatInterface $text_format, Fundam
$text_format,
FilterInterface::TYPE_MARKUP_LANGUAGE
);
if (!empty($markup_filters)) {
foreach ($markup_filters as $markup_filter) {
$this->context->buildViolation($constraint->noMarkupFiltersMessage)
->setParameter('%filter_label', $markup_filter->getLabel())
......@@ -92,7 +91,6 @@ private function checkNoMarkupFilters(FilterFormatInterface $text_format, Fundam
->addViolation();
}
}
}
/**
* Checks that fundamental CKEditor 5 plugins' HTML tags are allowed.
......@@ -194,25 +192,21 @@ private function checkHtmlRestrictionsMatch(EditorInterface $text_editor, Fundam
* conditions to be met. Must return TRUE when it meets the conditions,
* FALSE otherwise.
*
* @return \Drupal\filter\Plugin\FilterInterface[]
* The matched filter plugins.
* @return iterable|\Drupal\filter\Plugin\FilterInterface[]
* An iterable of matched filter plugins.
*/
private static function getFiltersInFormatOfType(FilterFormatInterface $text_format, int $filter_type, callable $extra_requirements = NULL): array {
private static function getFiltersInFormatOfType(FilterFormatInterface $text_format, int $filter_type, callable $extra_requirements = NULL): iterable {
assert(in_array($filter_type, [
FilterInterface::TYPE_MARKUP_LANGUAGE,
FilterInterface::TYPE_HTML_RESTRICTOR,
FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
]));
return array_filter($text_format->filters()->getAll(), function (FilterInterface $filter) use ($filter_type, $extra_requirements) {
if (!$filter->status) {
return FALSE;
foreach ($text_format->filters() as $id => $filter) {
if ($filter->status && $filter->getType() === $filter_type && ($extra_requirements === NULL || $extra_requirements($filter))) {
yield $id => $filter;
}
if ($filter->getType() === $filter_type && ($extra_requirements === NULL || $extra_requirements($filter))) {
return TRUE;
}
return FALSE;
});
}
/**
......
......@@ -517,8 +517,8 @@ public function provider() {
'expected_superset' => '<br> <p>',
'expected_fundamental_compatibility_violations' => [
'' => [
0 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.',
1 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.',
0 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.',
1 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.',
],
],
'expected_messages' => [
......
......@@ -416,7 +416,7 @@ public function providerPair(): array {
'id' => 'filter_url',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'weight' => -10,
'settings' => [
'filter_url_length' => 72,
],
......@@ -429,6 +429,43 @@ public function providerPair(): array {
],
],
];
$data['INVALID: non-HTML format: filter_autop + filter_url (different order)'] = [
'settings' => [
'toolbar' => [
'items' => [
'bold',
],
],
'plugins' => [],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_autop' => [
'id' => 'filter_autop',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [],
],
'filter_url' => [
'id' => 'filter_url',
'provider' => 'filter',
'status' => TRUE,
'weight' => 10,
'settings' => [
'filter_url_length' => 72,
],
],
],
'violations' => [
'' => [
'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.',
'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.',
],
],
];
$data['INVALID: forbidden tags'] = [
'settings' => [
'toolbar' => [
......@@ -456,7 +493,7 @@ public function providerPair(): array {
'' => 'CKEditor 5 needs at least the &lt;p&gt; and &lt;br&gt; tags to be allowed to be able to function. They are forbidden by the "<em class="placeholder">Tag and attribute restricting filter</em>" (<em class="placeholder">filter_test_restrict_tags_and_attributes</em>) filter.',
],
];
$restricted_html_format_filters = Yaml::parseFile('profiles/standard/config/install/filter.format.restricted_html.yml')['filters'];
$restricted_html_format_filters = Yaml::parseFile(__DIR__ . '/../../../../../profiles/standard/config/install/filter.format.restricted_html.yml')['filters'];
$data['INVALID: the default restricted_html text format'] = [
'settings' => [
'toolbar' => [
......@@ -470,8 +507,8 @@ public function providerPair(): array {
'filters' => $restricted_html_format_filters,
'violations' => [
'' => [
'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.',
'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.',
'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.',
],
],
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment