Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: third_party/google-endpoints/future/moves/html/__init__.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 from __future__ import absolute_import
2 from future.utils import PY3
3 __future_module__ = True
4
5 if PY3:
6 from html import *
7 else:
8 # cgi.escape isn't good enough for the single Py3.3 html test to pass.
9 # Define it inline here instead. From the Py3.4 stdlib. Note that the
10 # html.escape() function from the Py3.3 stdlib is not suitable for use on
11 # Py2.x.
12 """
13 General functions for HTML manipulation.
14 """
15
16 def escape(s, quote=True):
17 """
18 Replace special characters "&", "<" and ">" to HTML-safe sequences.
19 If the optional flag quote is true (the default), the quotation mark
20 characters, both double quote (") and single quote (') characters are al so
21 translated.
22 """
23 s = s.replace("&", "&amp;") # Must be done first!
24 s = s.replace("<", "&lt;")
25 s = s.replace(">", "&gt;")
26 if quote:
27 s = s.replace('"', "&quot;")
28 s = s.replace('\'', "&#x27;")
29 return s
30
31 __all__ = ['escape']
OLDNEW
« no previous file with comments | « third_party/google-endpoints/future/moves/dbm/ndbm.py ('k') | third_party/google-endpoints/future/moves/html/entities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698