mirror of https://github.com/zulip/zulip.git
emails: Fix duplicate <html> blocks in missed-message emails.
Apparently, the missed-message templates have a slightly different structure from our other email templates, which triggered a latent, subtle bug in inline-email-css's effort to remove duplicate <html> blocks from emails that had been generated by premailer. Fix this bug, and add appropriate assertions to prevent similar issues in the future. Fixes #11249.
This commit is contained in:
parent
4219cc497d
commit
e29533df0f
|
@ -59,10 +59,21 @@ if __name__ == "__main__":
|
|||
# template, since we'll end up with 2 copipes of those tags.
|
||||
# Thus, we strip this stuff out if the template extends
|
||||
# another template.
|
||||
end_block = '</body>\n</html>'
|
||||
start = output.find('{% extends')
|
||||
end = output.find('{% endblock %}</body>\n</html>')
|
||||
end = output.rfind(end_block)
|
||||
if start != -1 and end != -1:
|
||||
output = output[start:end+len('{% endblock %}')]
|
||||
output = output[start:end]
|
||||
else:
|
||||
# Only the base-default template should not be using this system.
|
||||
assert template == 'email_base_default'
|
||||
|
||||
if ('zerver/emails/compiled/email_base_default.html' in output or
|
||||
'zerver/emails/email_base_messages.html' in output):
|
||||
assert output.count('<html>') == 0
|
||||
assert output.count('<body>') == 0
|
||||
assert output.count('</html>') == 0
|
||||
assert output.count('</body>') == 0
|
||||
|
||||
with open(compiled_template_path, 'w') as final_template_file:
|
||||
final_template_file.write(output)
|
||||
|
|
Loading…
Reference in New Issue