On Tuesday, November 15, 2016 at 4:23:53 PM UTC-8, 黄祥 wrote:
>
> let say i have a text field that filled with the html tags, how should i
> use the represent for that?
> *e.g.*
> db.define_table('mail_queue',
> Field('mail_to', 'list:string'),
> Field('subject'),
> Field('messages', 'text'),
> Field('status'),
> format = lambda r: '%s - %s - %s' % (r.mail_to, r.subject, r.status) )
>
> db.mail_queue.messages.represent = lambda value, field: XML(value,
> sanitize = False) if value else ''
>
You may want to use response.render() in your controller.
<http://web2py.com/books/default/chapter/29/08/emails-and-sms#Using-the-template-system-to-generate-messages>
There is also the MARKMIN() helper, which could give you an alternate
input/render combination.
<URL:http://web2py.com/books/default/chapter/29/03/overview#MARKMIN-basics>
<URL:http://web2py.com/books/default/chapter/29/05/the-views#MARKMIN>
what i want to achieve is the messages field show html tag work result, but
> sanitize = False will open a XSS attack, isn't it?
>
> db.mail_queue.messages.represent = lambda value, field: XML(value,
> sanitize = True) if value else ''
>
> sanitize = True will not shown the html tag work result, just the html tag.
>
> any idea?
>
> thanks and best regards,
> stifan
>
Good luck!
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.