Issue #3305621 by longwave, Wim Leers: HTMLRestrictions::mergeAllowedElementsLevel() fails when merging <ol type="1">

merge-requests/2673/head
Lauri Eskola 2022-08-24 18:17:11 +03:00
parent 7e4c0f9675
commit 1921b1bddf
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
2 changed files with 12 additions and 2 deletions

View File

@ -759,8 +759,11 @@ final class HTMLRestrictions {
} }
// Make sure the order of the union array matches the order of the keys in // Make sure the order of the union array matches the order of the keys in
// the arrays provided. // the arrays provided.
$keys_order = array_merge($array1_keys, $array2_keys); $ordered = [];
return array_merge(array_flip($keys_order), $union); foreach (array_merge($array1_keys, $array2_keys) as $key) {
$ordered[$key] = $union[$key];
}
return $ordered;
} }
/** /**

View File

@ -997,6 +997,13 @@ class HTMLRestrictionsTest extends UnitTestCase {
'intersection' => 'a', 'intersection' => 'a',
'union' => 'b', 'union' => 'b',
]; ];
yield 'attribute restrictions are the same: <ol type="1"> vs <ol type="1">' => [
'a' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'b' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'a',
];
// Complex cases. // Complex cases.
yield 'attribute restrictions are different: <a hreflang="en"> vs <strong>' => [ yield 'attribute restrictions are different: <a hreflang="en"> vs <strong>' => [