This is a security release to address a denial of service vulnerability in the AttributesExtension.
Added
- Added a new
table_of_contents/max_placeholder_entriesoption to limit how many table of contents entries a document may render across all of its placeholders (#1134) - Added
Cursor::matchInPlace(), which matches a regular expression at the cursor's position within the line using PCRE's native offset semantics instead of copying the remainder (#1145)\Ganchors at the cursor,^anchors at the start of the line, and lookbehinds and\bsee the characters actually preceding the cursor; this keeps scanning loops linear and enables left-context assertions thatmatch()cannot express
- Added
RegexHelper::PARTIAL_LINK_TITLE_UNANCHOREDandRegexHelper::PARTIAL_LINK_DESTINATION_BRACES, unanchored fragments so each call site can supply its own anchor - Added a
default_attributesconfiguration format which pairs the node attribute map with a newstrict_callablesoption:['default_attributes' => ['attributes' => [...], 'strict_callables' => true]]. Withstrict_callablesenabled, only closures and invokable objects are treated as callbacks, so strings and arrays are always used as literal attribute values. Callbacks written as string or array callables can be wrapped withClosure::fromCallable(). The original format - passing the node map directly - is still accepted, and defaultsstrict_callablestofalse. - Added a new
slug_normalizer/reservedoption which treats the given slugs as already-used, so colliding headings receive an incremental numeric suffix just like duplicate headings do (#1080)
Changed
- Changed the
TableOfContentsextension to render the table of contents once and share it across all placeholders instead of cloning it into each one (#1134)- A custom renderer registered for the
TableOfContentsnode is no longer called once per placeholder, so it must return the same markup each time it is called for a given document (#1134) - The first placeholder receives the table of contents itself, so a document still contains a
TableOfContentsnode for listeners which locate and reposition it (#1143)
- A custom renderer registered for the
$environment->getConfiguration()->get('default_attributes')now returns the normalized structure withattributesandstrict_callableskeys instead of the node map; readdefault_attributes/attributesto get the map. Configuration written in either format continues to work unchanged.
Deprecated
- Deprecated
RegexHelper::PARTIAL_LINK_TITLEandRegexHelper::REGEX_LINK_DESTINATION_BRACES; use the unanchored variants with an explicit anchor instead - Deprecated the
default_attributesstrict_callablesoption, which will be removed in 3.0 when only closures and invokable objects will ever be treated as callbacks.
Fixed
- Fixed
default_attributesvalues which happen to match the name of a PHP function - such as'class' => 'link','header','key','range', or'current'- being invoked as callbacks, producing errors likelink() expects exactly 2 arguments, 1 given. Enablestrict_callablesto treat strings and arrays as literal attribute values (#1123) - Fixed the
DefaultAttributesExtensionre-testing every configured value withis_callable()once per matching node, which asked the autoloader whether the first element of each array value named a real class every single time - Fixed a
default_attributesvalue which PHP treats as callable reporting its failure from inside whichever function it collided with; the error now names the attribute and node class responsible, and keeps the original error as its previous exception - Fixed custom
UniqueSlugNormalizerInterfaceimplementations being wrapped by the built-inUniqueSlugNormalizerand never receiving the documentedclearHistory()calls, which caused slug history to leak across documents whenslug_normalizer/uniquewas set to'document'(#1080)- Custom implementations are now trusted to enforce uniqueness themselves, per the interface contract; the extra deduplication layer the wrapper used to provide is no longer applied on top of them
- Fixed the
AttributesExtensionre-merging and re-filtering everything a node had already collected each time another attribute node was applied to it, causing long runs of distinctly-named attributes to be resolved in quadratic time, which could be abused to cause a denial of service - this completes the fix for GHSA-jjv6-8j6v-6j52, which covered only theclassattribute (GHSA-8rr7-cvq3-gmfh) - Fixed the
AttributesExtensionre-merging everything an attribute block had already collected on each of its continuation lines, causing long runs of distinctly-named attributes on consecutive lines to be resolved in quadratic time, which could be abused to cause a denial of service (GHSA-8rr7-cvq3-gmfh)