zulip/zerver
Alex Vandiver fa6daee4e1 markdown: Fix use of pure_markdown for non-pure markdown rendering.
`render_markdown_path` renders Markdown, and also (since baff121115)
runs Jinja2 on the resulting HTML.

The `pure_markdown` flag was added in 0a99fa2fd6, and did two
things: retried the path directly in the filesystem if it wasn't found
by the Jinja2 resolver, and also skipped the subsequent Jinja2
templating step (regardless of where the content was found).  In this
context, the name `pure_markdown` made some sense.  The only two
callsites were the TOS and privacy policy renders, which might have
had user-supplied arbitrary paths, and we wished to handle absolute
paths in addition to ones inside `templates/`.

Unfortunately, the follow-up of 01bd55bbcb did not refactor the
logic -- it changed it, by making `pure_markdown` only do the former
of the two behaviors.  Passing `pure_markdown=True` after that commit
still caused it to always run Jinja2, but allowed it to look elsewhere
in the filesystem.

This set the stage for calls, such as the one introduced in
dedea23745, which passed both a context for Jinja2, as well as
`pure_markdown=True` implying that Jinja2 was not to be used.

Split the two previous behaviors of the `pure_markdown` flag, and use
pre-existing data to control them, rather than an explicit flag.  For
handling policy information which is stored at an absolute path
outside of the template root, we switch to using the template search
path if and only if the path is relative.  This also closes the
potential inconsistency based on CWD when `pure_markdown=True` was
passed and the path was relative, not absolute.

Decide whether to run Jinja2 based on if a context is passed in at
all.  This restores the behavior in the initial 0a99fa2fd6 where a
call to `rendar_markdown_path` could be made to just render markdown,
and not some other unmentioned and unrelated templating language as
well.
2023-03-17 08:46:25 -07:00
..
actions invites: Switch new LIMITED-plan heuristic to enforcing. 2023-03-16 11:41:49 -07:00
data_import upload: Rename upload_message_file to use word "attachment". 2023-03-02 16:36:19 -08:00
integration_fixtures/nagios
lib markdown: Fix use of pure_markdown for non-pure markdown rendering. 2023-03-17 08:46:25 -07:00
management templates: Allow the same line-wrapping in {{t}} as in {{#tr}}. 2023-03-16 11:26:45 -07:00
migrations user_settings: Automate 'Include realm name in message email subject'. 2023-03-14 17:48:57 -07:00
openapi UserTopic: Set visibility_policy or delete UserTopic row without error. 2023-03-16 10:55:54 -07:00
tests markdown: Fix use of pure_markdown for non-pure markdown rendering. 2023-03-17 08:46:25 -07:00
tornado tornado: Replace dataclasses.asdict() call, as it is slow. 2023-02-23 11:01:38 -08:00
views user_topics: Introduce visibility policy enum subclass in models.py. 2023-03-14 17:50:45 -07:00
webhooks integration: Modify branch names on pull request events. 2023-03-16 11:31:48 -07:00
worker deferred_work: Log at start of the work. 2023-02-09 12:06:38 -08:00
__init__.py
apps.py sentry: Initialize sentry in AppConfig ready hook. 2022-09-26 12:42:36 -07:00
context_processors.py sentry: Enable reporting on portico and other unauth pages. 2023-03-07 15:01:27 -08:00
decorator.py request-notes: Add `is_webhook_view` boolean to fields. 2023-03-06 10:33:13 -08:00
filters.py
forms.py registration: Add code to set email_address_visibility during signup. 2023-02-24 09:23:34 -08:00
logging_handlers.py python: Use Python 3.8 typing.{Protocol,TypedDict}. 2022-04-27 12:57:49 -07:00
middleware.py ruff: Fix PIE810 Call `startswith` once with a `tuple`. 2023-02-08 16:40:35 -08:00
models.py user_topics: Introduce visibility policy enum subclass in models.py. 2023-03-14 17:50:45 -07:00
signals.py requirements: Upgrade to Django 4.0. 2022-07-13 16:07:17 -07:00