mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
api docs: Escape HTML in the examples.
Having HTML (or HTML-like) content in the examples was making parts of the content invisible, since the browser identified them as HTML tags rather than verbose text.
This commit is contained in:
committed by
Tim Abbott
parent
c70d051031
commit
df7234f3a6
@@ -2,6 +2,7 @@ import re
|
|||||||
import os
|
import os
|
||||||
import ujson
|
import ujson
|
||||||
|
|
||||||
|
from django.utils.html import escape as escape_html
|
||||||
from markdown.extensions import Extension
|
from markdown.extensions import Extension
|
||||||
from markdown.preprocessors import Preprocessor
|
from markdown.preprocessors import Preprocessor
|
||||||
from zerver.lib.openapi import get_openapi_parameters
|
from zerver.lib.openapi import get_openapi_parameters
|
||||||
@@ -133,7 +134,7 @@ class APIArgumentsTablePreprocessor(Preprocessor):
|
|||||||
argument=argument.get('argument') or argument.get('name'),
|
argument=argument.get('argument') or argument.get('name'),
|
||||||
# Show this as JSON to avoid changing the quoting style, which
|
# Show this as JSON to avoid changing the quoting style, which
|
||||||
# may cause problems with JSON encoding.
|
# may cause problems with JSON encoding.
|
||||||
example=ujson.dumps(argument['example']),
|
example=escape_html(ujson.dumps(argument['example'])),
|
||||||
required='Yes' if argument.get('required') else 'No',
|
required='Yes' if argument.get('required') else 'No',
|
||||||
description=md_engine.convert(description),
|
description=md_engine.convert(description),
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user