Skip to content
Myr

Docs: Fix escaping in HTML escaping example (#5742)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 7fea7cf, 0f83958 · Browse files · 1 file+6 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−8 removed

  • other:+6 added−8 removed

1 file+6 added−8 removed

modified:docs/quickstart.rst+6 added-8 removed
137 unmodified lines
138how you're using untrusted data.139140.. code-block:: python141142 from flask import request143 from markupsafe import escape144144 @app.route("/<name>")145 def hello(name):145 @app.route("/hello")146 def hello():147 name = request.args.get("name", "Flask")148 return f"Hello, {escape(name)}!"149148If a user managed to submit the name ``<script>alert("bad")</script>``,149escaping causes it to be rendered as text, rather than running the150script in the user's browser.150If a user submits ``/hello?name=<script>alert("bad")</script>``, escaping causes151it to be rendered as text, rather than running the script in the user's browser.152152``<name>`` in the route captures a value from the URL and passes it to153the view function. These variable rules are explained below.153155154Routing155-------156157Modern web applications use meaningful URLs to help users. Users are more
748 unmodified lines