Skip to content

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

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

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

Conversation

@Syed-Ali-Abbas-568

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 4b27545 into develop-teak Jul 31, 2026
19 of 23 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.

1 participant