Anthony
Anthony

Reputation: 39

Web2py (save) use of HTML tags in database (text) dleid

How can you, in a safe way, enter (en render) hmtl tags in a web2py database textfield. Entered by an end user?

Upvotes: 0

Views: 199

Answers (1)

Anthony
Anthony

Reputation: 25536

You can save the HTML in the database as you receive it, and then render it (relatively) safely via:

{{=XML(html, sanitize=True)}}

XML() also takes permitted_tags and allowed_attributes arguments for more fine-grained control. For details, see the book.

Upvotes: 2

Related Questions