From d4b9b9854c7afb32c4c2ee27c4d98def1c8e22ca Mon Sep 17 00:00:00 2001 From: defuz Date: Wed, 5 Nov 2014 07:43:00 +0300 Subject: [PATCH] docs: :mimetype:`application/json` --- docs/htmlfaq.rst | 2 +- docs/patterns/apierrors.rst | 2 +- docs/quickstart.rst | 2 +- docs/security.rst | 4 ++-- flask/json.py | 2 +- flask/wrappers.py | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/htmlfaq.rst b/docs/htmlfaq.rst index fdf29634..cba99fa1 100644 --- a/docs/htmlfaq.rst +++ b/docs/htmlfaq.rst @@ -16,7 +16,7 @@ However, barely any websites on the Internet are actual XHTML (which is HTML processed using XML rules). There are a couple of major reasons why this is the case. One of them is Internet Explorer's lack of proper XHTML support. The XHTML spec states that XHTML must be served with the MIME -type `application/xhtml+xml`, but Internet Explorer refuses to read files +type :mimetype:`application/xhtml+xml`, but Internet Explorer refuses to read files with that MIME type. While it is relatively easy to configure Web servers to serve XHTML properly, few people do. This is likely because properly using XHTML can be quite diff --git a/docs/patterns/apierrors.rst b/docs/patterns/apierrors.rst index b06966e6..ce5c8446 100644 --- a/docs/patterns/apierrors.rst +++ b/docs/patterns/apierrors.rst @@ -4,7 +4,7 @@ Implementing API Exceptions It's very common to implement RESTful APIs on top of Flask. One of the first thing that developers run into is the realization that the builtin exceptions are not expressive enough for APIs and that the content type of -``text/html`` they are emitting is not very useful for API consumers. +:mimetype:`text/html` they are emitting is not very useful for API consumers. The better solution than using ``abort`` to signal errors for invalid API usage is to implement your own exception type and install an error handler diff --git a/docs/quickstart.rst b/docs/quickstart.rst index f082f9c8..651356e9 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -708,7 +708,7 @@ About Responses The return value from a view function is automatically converted into a response object for you. If the return value is a string it's converted into a response object with the string as response body, a ``200 OK`` -status code and a ``text/html`` mimetype. The logic that Flask applies to +status code and a :mimetype:`text/html` mimetype. The logic that Flask applies to converting return values into response objects is as follows: 1. If a response object of the correct type is returned it's directly diff --git a/docs/security.rst b/docs/security.rst index e5703274..d1920f3a 100644 --- a/docs/security.rst +++ b/docs/security.rst @@ -161,8 +161,8 @@ and social engineers a victim to visiting his site: If you know a bit of JavaScript internals you might know that it's possible to patch constructors and register callbacks for setters. An attacker can use this (like above) to get all the data you exported in -your JSON file. The browser will totally ignore the ``application/json`` -mimetype if ``text/javascript`` is defined as content type in the script +your JSON file. The browser will totally ignore the :mimetype:`application/json` +mimetype if :mimetype:`text/javascript` is defined as content type in the script tag and evaluate that as JavaScript. Because top-level array elements are allowed (albeit useless) and we hooked in our own constructor, after that page loaded the data from the JSON response is in the `captured` array. diff --git a/flask/json.py b/flask/json.py index 318fe28b..c895a446 100644 --- a/flask/json.py +++ b/flask/json.py @@ -200,7 +200,7 @@ def htmlsafe_dump(obj, fp, **kwargs): def jsonify(*args, **kwargs): """Creates a :class:`~flask.Response` with the JSON representation of - the given arguments with an `application/json` mimetype. The arguments + the given arguments with an :mimetype:`application/json` mimetype. The arguments to this function are the same as to the :class:`dict` constructor. Example usage:: diff --git a/flask/wrappers.py b/flask/wrappers.py index 110a99c3..738cbb12 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -98,7 +98,7 @@ class Request(RequestBase): @property def json(self): - """If the mimetype is `application/json` this will contain the + """If the mimetype is :mimetype:`application/json` this will contain the parsed JSON data. Otherwise this will be ``None``. The :meth:`get_json` method should be used instead. @@ -112,7 +112,7 @@ class Request(RequestBase): def is_json(self): """Indicates if this request is JSON or not. By default a request is considered to include JSON data if the mimetype is - ``application/json`` or ``application/*+json``. + :mimetype:`application/json` or :mimetype:`application/*+json`. .. versionadded:: 0.11 """ @@ -127,7 +127,7 @@ class Request(RequestBase): """Parses the incoming JSON request data and returns it. If parsing fails the :meth:`on_json_loading_failed` method on the request object will be invoked. By default this function will - only load the json data if the mimetype is ``application/json`` + only load the json data if the mimetype is :mimetype:`application/json` but this can be overridden by the `force` parameter. :param force: if set to ``True`` the mimetype is ignored.