2.10.0
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)
2.9.2
This release fixes a regression introduced in 2.9.0 which changed the behavior of Cursor::match() for certain regular expression patterns.
Changed
- Improved performance of reading single characters from multibyte lines
- Improved performance of locating the next non-space character on lines without tabs
- Optimized
Cursor::advanceToNextNonSpaceOrNewline()to scan the line in place instead of copying everything left in the block on every call - Optimized inline link destination parsing to scan the line in place, so its cost follows the length of the destination rather than the length of everything left in the block
Fixed
- Fixed a regression introduced in 2.9.0 where
Cursor::match()treated text before the cursor as part of the match subject (#1145). Patterns were matched against the whole line at an offset, which silently changed the meaning of\b,\B,\A, lookbehinds, a^anywhere other than the very start of the pattern, and a leading^combined with themmodifier.match()once again matches against the remainder, exactly as it did in 2.8; the core parsers keep the optimized in-place matching via a new internal method with PCRE's native offset semantics, anchoring their patterns at the cursor with\G - Fixed heading permalinks rendered with
aria-hidden="true"remaining in the keyboard tab order; they are now also giventabindex="-1", as a focusable element removed from the accessibility tree has no accessible name to announce when focused (WCAG 4.1.2) - Fixed cloning a node breaking the link from the original node's children back to their parent, silently corrupting the document that node belonged to; detaching or inserting around those children afterwards could drop nodes from the tree
- Fixed cloned nodes sharing their
datawith the node they were cloned from, so that setting an attribute on either one also set it on the other
2.9.1
This is a security release to address multiple denial-of-service vulnerabilities and one cross-site scripting (XSS) vulnerability.
Changed
- Shortcut and collapsed reference links (
[label]and[label][]) now apply the spec's 999-character link label limit when resolving the label, matching the limit already enforced when parsing reference definitions and when resolving the[text][label]form. A label longer than 999 characters which collapsed to a shorter, defined label once whitespace was normalized will no longer resolve; this matches cmark's behavior.
Fixed
- Fixed attribute names prefixed with a form feed (such as
{<FF>onclick="..."}) bypassing both theon*event handler filter and theallow_unsafe_linksprotection, as browsers treat that byte as whitespace and parse the name as a genuineonclickorhref(GHSA-f8fg-pg57-v4j8) - Fixed catastrophic backtracking in the fenced code block start pattern, causing a single line of backticks to be scanned in quadratic time, which could be abused to cause a denial of service (GHSA-j8pm-gj4c-rq4x)
- Fixed shortcut reference link lookups normalizing arbitrarily long labels once a single reference definition is present, causing nested brackets to be resolved in quadratic time, which could be abused to cause a denial of service (GHSA-j8pm-gj4c-rq4x)
- Fixed delimiter processors keying the opener-search cache on the raw closer run length, leaving the cache key space unbounded and causing emphasis, strikethrough, and highlight runs to be processed in super-linear time, which could be abused to cause a denial of service (GHSA-j8pm-gj4c-rq4x)
- Fixed the
SmartPunctExtensionrecopying the whole preceding text node when replacing each unpaired quote, causing documents with many apostrophes to be processed in quadratic time, which could be abused to cause a denial of service (GHSA-jjv6-8j6v-6j52) - Fixed the
AttributesExtensionscanning the remaining siblings of every block-level attribute node, causing long runs of adjacent attribute blocks to be resolved in quadratic time, which could be abused to cause a denial of service - this completes the fix for GHSA-g2gp-3wwq-f4ph, which covered only inline attributes (GHSA-jjv6-8j6v-6j52) - Fixed the
AttributesExtensionrebuilding the accumulated class list on every merge, causing long runs of.classattributes to be resolved in quadratic time, which could be abused to cause a denial of service (GHSA-jjv6-8j6v-6j52)
2.9.0
This is a security release to address five denial-of-service vulnerabilities and one cross-site scripting (XSS) vulnerability.
Added
- Added a new
NormalizeHeadingsExtensionto constrain headings to a configured level range (#989)- Rewrites headings that skip levels so the resulting HTML is valid (#1115)
normalize_headings/rebase_to_min_level- rebases each document so its headings begin atmin_level
- Added a new
footnote/enable_inline_footnotesconfig option to disable the inline^[Footnote text]syntax (#1112) - Added
Cursor::getBytePosition()for obtaining the cursor's current byte offset within the line - Added a new
xml/max_indentation_levelconfig option to control how farXmlRendererindents nested elements (default:16; set to0for unindented output)
Changed
- The
FootnoteExtensionnow uses only the first definition of a footnote label, removing any duplicate definitions instead of rendering them in place NumberFootnotesListenernow stores footnote backrefs under a singlefootnote/backrefskey in the document data instead of one key per footnote destination- Optimized
Cursorto translate character positions to byte offsets in constant time instead of re-decoding the line withmb_substr() - Optimized
Cursor::match()to match against the line at the cursor's byte offset instead of copying the remaining line on every call - Optimized
InlineParserEngineandUrlAutolinkParserto work with byte offsets directly
Fixed
- Fixed quadratic parsing performance on lines containing multibyte characters, which could be abused to cause a denial of service (GHSA-2q4p-g7hv-5rgv)
- Fixed the unsafe link filter failing to detect dangerous schemes obfuscated with embedded tabs, newlines, or leading control characters (such as
java<TAB>script:), which allowed theallow_unsafe_linksprotection to be bypassed viahrefandsrcattributes (GHSA-29pj-957v-52mc) - Fixed duplicate footnote definitions each claiming the full list of backrefs for their label, causing a quadratic number of backrefs to be generated, which could be abused to cause a denial of service (GHSA-jfm3-95jq-q3rf)
- Fixed footnote labels being treated as
.//-delimited key paths when storing backrefs, which allowed distinct labels such as[^a.b]and[^a/b]to share a single backref list (GHSA-jfm3-95jq-q3rf) - Fixed a fatal error when one footnote label was a prefix of another, such as
[^a]and[^a.b] - Fixed the unique slug normalizer restarting its suffix search from
1on every collision, causing headings or inline footnotes which normalize to the same slug to be de-duplicated in quadratic time, which could be abused to cause a denial of service (GHSA-mh25-x5hq-wrqp) - Fixed the
AttributesExtensionscanning the remaining siblings of an inline attribute which can only apply to its parent block, causing long runs of adjacent inline attributes to be resolved in quadratic time, which could be abused to cause a denial of service (GHSA-g2gp-3wwq-f4ph) - Fixed
XmlRendererindenting every element by its full nesting depth without any upper bound, causing deeply-nested documents to render as quadratically-sized XML, which could be abused to cause a denial of service (GHSA-mj63-m3rc-8ppr) - Fixed
MarkDelimiterProcessornot being declared as aCacheableDelimiterProcessorInterface, preventing the delimiter stack from caching the opener search for==runs (#1133)
New Contributors
- @AJenbo made their first contribution in #1108
- @eyupcanakman made their first contribution in #1113
Special Thanks
Special thanks to @GrahamCampbell and @TungNGo02 for responsibly disclosing the security vulnerabilities and contributing to the fixes in this release.
Full Changelog: 2.8.3...2.9.0
2.8.3
What's Changed
Fixed
- Fixed tab-indented fenced code blocks inside list items losing the first character of each line and having their info string mangled (#981, #1130)
- Fixed the unsafe link filter incorrectly blocking safe URLs containing
vbscript:,file:, ordata:anywhere after the start (#1131)
Full Changelog: 2.8.2...2.8.3
2.8.2
This is a security release to address an issue where the allowed_domains setting for the Embed extension can be bypassed, resulting in a possible SSRF and XSS vulnerabilities.
Fixed
- Fixed
DomainFilteringAdapterhostname boundary bypass where domains likeyoutube.com.evilcould match an allowlist entry foryoutube.com(GHSA-hh8v-hgvp-g3f5)
Full Changelog: 2.8.1...2.8.2
2.8.1
What's Changed
This is a security release to address an issue where DisallowedRawHtml can be bypassed, resulting in a possible cross-site scripting (XSS) vulnerability.
Fixed
- Fixed
DisallowedRawHtmlRenderernot blocking raw HTML tags with trailing ASCII whitespace (GHSA-4v6x-c7xx-hw9f) - Fixed PHP 8.5 deprecation (#1107)
New Contributors
Full Changelog: 2.8.0...2.8.1
2.8.0
What's Changed
Added
- Added a new
HighlightExtensionfor marking important text using==syntax (#1100)
Fixed
New Contributors
- @samwilson made their first contribution in #1090
- @ossobuffo made their first contribution in #1100
Full Changelog: 2.7.1...2.8.0
2.7.1
Notable Changes
Changed
Fixed
EmbedProcessorno longer callsupdateEmbeds()when there are no embeds to update (#1081)- Fixed missing
benchmark.phpCSV path validation for non-existent files (#1068, #1085)
New Contributors
- @driesvints made their first contribution in #1077
- @adielcristo made their first contribution in #1079
- @Copilot made their first contribution in #1085
Full Changelog: 2.7.0...2.7.1