Skip to content

fix: guard against None/empty input in clean_dangerous_html - #662

Merged
Syed-Ali-Abbas-568 merged 1 commit into
developfrom
syed-ali/fix-clean-dangerous-html
Jul 31, 2026
Merged

fix: guard against None/empty input in clean_dangerous_html#662
Syed-Ali-Abbas-568 merged 1 commit into
developfrom
syed-ali/fix-clean-dangerous-html

Conversation

@Syed-Ali-Abbas-568

@Syed-Ali-Abbas-568 Syed-Ali-Abbas-568 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Problem

Course about page (/about) throws a 500 error when the course overview
is None or whitespace-only. clean_dangerous_html passes the value
directly to lxml, which returns None for empty input, causing:
AttributeError: 'NoneType' object has no attribute 'getroottree'

Fix

Updated the null check in clean_dangerous_html (markup.py) to also
catch whitespace-only strings, and return HTML('') instead of the
raw None to stay consistent with the function's return type.

Changes

  • openedx/core/djangolib/markup.py — added html.strip() check and fixed return value

Note: this issue was previously fixed in #615 but the fix was not ported over to develop when upgrading.

@Syed-Ali-Abbas-568
Syed-Ali-Abbas-568 merged commit 1b941e7 into develop Jul 31, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants