Created
June 4, 2010 08:28
-
-
Save qoelet/425152 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mark_safe(s): | |
""" | |
Explicitly mark a string as safe for (HTML) output purposes. The returned | |
object can be used everywhere a string or unicode object is appropriate. | |
Can be called multiple times on a single string. | |
""" | |
if isinstance(s, SafeData): | |
return s | |
if isinstance(s, str) or (isinstance(s, Promise) and s._delegate_str): | |
return SafeString(s) | |
if isinstance(s, (unicode, Promise)): | |
return SafeUnicode(s) | |
return SafeString(str(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment