fix: stop double HTML-escaping course name in enrollment emails#754
Draft
Waleed-Mujahid wants to merge 1 commit into
Draft
fix: stop double HTML-escaping course name in enrollment emails#754Waleed-Mujahid wants to merge 1 commit into
Waleed-Mujahid wants to merge 1 commit into
Conversation
Backport of openedx#31995 to Koa. Course titles containing '&' (or <, >, ") rendered as "CICT&L" in instructor enrollment/beta emails. Two escapes stacked: - get_email_params / send_mail_to_student pre-escaped course_name with Text() (markupsafe.escape); and - the edx-ace body.html templates escaped it again -- {% blocktrans %} runs under autoescape-on AND was wrapped in {% filter force_escape %}. Drop the Text() wrapper (templates own the escaping) and, in the HTML bodies, switch the course_name blocktrans blocks from force_escape to {% autoescape off %} + xss-lint disable, matching openedx#31995. Subject and body.txt already use {% autoescape off %}, so removing Text() sufficed there. Also converts one block openedx#31995 missed: accountcreationandenrollment "Sincerely yours, The {course_name} Team". The addbetatester asvar CTA block is left as upstream (different rendering path).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Course titles containing
&(or<,>,") render asCICT&Lin instructor enrollment/beta emails. Reported on Koa for a course named "Cambridge International Certificate in Teaching & Learning CICT&L 5881 Unit One (Pilot)".Root cause — two escapes stacked
get_email_params/send_mail_to_studentwrappedcourse_nameinText()(=markupsafe.escape) →&becomes&.{% blocktrans %}runs under autoescape-on and was wrapped in{% filter force_escape %}→ escapes a second time →&amp;→ renders&.The subject and body.txt use
{% autoescape off %}, so removingText()alone fixed those; the HTML body needed the template change too.Fix
Text()wrapper oncourse_name(both call sites) — templates own the escaping.body.htmltemplates, switchcourse_nameblocktrans blocks from{% filter force_escape %}to{% autoescape off %}+ xss-lint disable.Backport of upstream openedx/edx-platform#31995 ("fix subject email and body html code"), which fixed this on master but was never backported to the Koa release line. Cherry-pick isn't viable — that commit sits on 2023 master and conflicts across the whole repo on Koa.
Coverage / notes
addbetatester{% blocktrans asvar course_cta_text %}Visit {{ course_name }}{% endblocktrans %}block — different render path (feeds the CTA include); upstream left it untouched.Testing
Not run locally — Koa devstack not up in this environment. Relies on CI. No behavior change beyond escaping of
course_namein these emails.