Headline
CVE-2023-26303: π FIX: CVE-2023-26303 (#246) Β· executablebooks/markdown-it-py@ae03c61
Denial of service could be caused to markdown-it-py, before v2.2.0, if an attacker was allowed to force null assertions with specially crafted input.
@@ -83,8 +83,8 @@ def render(
for i, token in enumerate(tokens):
if token.type == "inline":
assert token.children is not None
result += self.renderInline(token.children, options, env)
if token.children:
result += self.renderInline(token.children, options, env)
elif token.type in self.rules:
result += self.rules[token.type](tokens, i, options, env)
else:
@@ -206,8 +206,8 @@ def renderInlineAsText(
if token.type == "text":
result += token.content
elif token.type == "image":
assert token.children is not None
result += self.renderInlineAsText(token.children, options, env)
if token.children:
result += self.renderInlineAsText(token.children, options, env)
elif token.type == "softbreak":
result += β\nβ
@@ -305,14 +305,10 @@ def image(
# βaltβ attr MUST be set, even if empty. Because itβs mandatory and
# should be placed on proper position for tests.
assert (
token.attrs and βaltβ in token.attrs
), β"image" token\βs attrs must contain `alt`β
# Replace content with actual value
token.attrSet("alt", self.renderInlineAsText(token.children, options, env))
if token.children:
token.attrSet("alt", self.renderInlineAsText(token.children, options, env))
else:
token.attrSet("alt", ββ)
return self.renderToken(tokens, idx, options, env)