Пример #1
0
def test_sanitize(app, dummy_request):

    from kotti.sanitizers import sanitize
    from kotti.resources import Document
    from kotti.views.util import TemplateAPI

    _verify_no_html(sanitize(unsanitized, 'no_html'))
    _verify_minimal_html(sanitize(unsanitized, 'minimal_html'))
    _verify_xss_protection(sanitize(unsanitized, 'xss_protection'))

    api = TemplateAPI(Document(), dummy_request)
    _verify_no_html(api.sanitize(unsanitized, 'no_html'))
    _verify_minimal_html(api.sanitize(unsanitized, 'minimal_html'))
    _verify_xss_protection(api.sanitize(unsanitized, 'xss_protection'))
Пример #2
0
    def sanitize(html, sanitizer='default'):
        """ Convenience wrapper for :func:`kotti.sanitizers.sanitize`.

        :param html: HTML to be sanitized
        :type html: unicode

        :param sanitizer: name of the sanitizer to use.
        :type sanitizer: str

        :result: sanitized HTML
        :rtype: unicode
        """

        return sanitize(html, sanitizer)
Пример #3
0
    def sanitize(html, sanitizer="default"):
        """ Convenience wrapper for :func:`kotti.sanitizers.sanitize`.

        :param html: HTML to be sanitized
        :type html: str

        :param sanitizer: name of the sanitizer to use.
        :type sanitizer: str

        :result: sanitized HTML
        :rtype: str
        """

        return sanitize(html, sanitizer)