Convert the characters &, <, >, ' and " in string s to HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. Marks return value as markup string.
(s)
| 13 | |
| 14 | |
| 15 | def escape(s): |
| 16 | """Convert the characters &, <, >, ' and " in string s to HTML-safe |
| 17 | sequences. Use this if you need to display text that might contain |
| 18 | such characters in HTML. Marks return value as markup string. |
| 19 | """ |
| 20 | if hasattr(s, '__html__'): |
| 21 | return s.__html__() |
| 22 | return Markup(text_type(s) |
| 23 | .replace('&', '&') |
| 24 | .replace('>', '>') |
| 25 | .replace('<', '<') |
| 26 | .replace("'", ''') |
| 27 | .replace('"', '"') |
| 28 | ) |
| 29 | |
| 30 | |
| 31 | def escape_silent(s): |
no test coverage detected