Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge-case crash in codehilite #1405

Merged
merged 1 commit into from Nov 3, 2023
Merged

Conversation

oprypin
Copy link
Contributor

@oprypin oprypin commented Nov 2, 2023

If there is an empty <pre><code></code></pre> inserted by another extension, there can be an exception. The added test case was crashing before this change:

  File "markdown/core.py", line 361, in convert
    newRoot = treeprocessor.run(root)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "markdown/extensions/codehilite.py", line 274, in run
    self.code_unescape(block[0].text),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "markdown/extensions/codehilite.py", line 260, in code_unescape
    text = text.replace("&lt;", "<")
           ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

If there is an empty `<pre><code></code></pre>` inserted by another extension, there can be an exception. The added test case was crashing before this change.
@waylan waylan merged commit f5b151a into Python-Markdown:master Nov 3, 2023
16 checks passed
@oprypin oprypin deleted the edgehilite branch November 3, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants