How to use the werkzeug.utils.escape function in Werkzeug

To help you get started, we’ve selected a few Werkzeug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tranquilit / WAPT / lib / site-packages / werkzeug / testapp.py View on Github external
def render_testapp(req):
    try:
        import pkg_resources
    except ImportError:
        eggs = ()
    else:
        eggs = sorted(pkg_resources.working_set,
                      key=lambda x: x.project_name.lower())
    python_eggs = []
    for egg in eggs:
        try:
            version = egg.version
        except (ValueError, AttributeError):
            version = 'unknown'
        python_eggs.append('<li>%s <small>[%s]</small>' % (
            escape(egg.project_name),
            escape(version)
        ))

    wsgi_env = []
    sorted_environ = sorted(req.environ.items(),
                            key=lambda x: repr(x[0]).lower())
    for key, value in sorted_environ:
        wsgi_env.append('%s<code>%s</code>' % (
            escape(str(key)),
            ' '.join(wrap(escape(repr(value))))
        ))

    sys_path = []
    for item, virtual, expanded in iter_sys_path():
        class_ = []
        if virtual:</li>
github pallets / werkzeug / werkzeug / contrib / atom.py View on Github external
for link in self.links:
            yield u'  \n' % ''.join('%s="%s" ' %
                                              (k, escape(link[k])) for k in link)
        for author in self.author:
            yield u'  \n'
            yield u'    %s\n' % escape(author['name'])
            if 'uri' in author:
                yield u'    %s\n' % escape(author['uri'])
            if 'email' in author:
                yield '    %s\n' % escape(author['email'])
            yield '  \n'
        if self.subtitle:
            yield '  ' + _make_text_block('subtitle', self.subtitle,
                                          self.subtitle_type)
        if self.icon:
            yield u'  %s\n' % escape(self.icon)
        if self.logo:
            yield u'  %s\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  %s\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
github pallets / werkzeug / werkzeug / contrib / atom.py View on Github external
def generate(self):
        """Yields pieces of ATOM XML."""
        base = ''
        if self.xml_base:
            base = ' xml:base="%s"' % escape(self.xml_base)
        yield u'\n' % base
        yield u'  ' + _make_text_block('title', self.title, self.title_type)
        yield u'  %s\n' % escape(self.id)
        yield u'  %s\n' % format_iso8601(self.updated)
        if self.published:
            yield u'  %s\n' % \
                  format_iso8601(self.published)
        if self.url:
            yield u'  \n' % escape(self.url)
        for author in self.author:
            yield u'  \n'
            yield u'    %s\n' % escape(author['name'])
            if 'uri' in author:
                yield u'    %s\n' % escape(author['uri'])
            if 'email' in author:
                yield u'    %s\n' % escape(author['email'])
github janeczku / calibre-web / vendor / werkzeug / contrib / atom.py View on Github external
yield '  ' + _make_text_block('subtitle', self.subtitle,
                                          self.subtitle_type)
        if self.icon:
            yield u'  %s\n' % escape(self.icon)
        if self.logo:
            yield u'  %s\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  %s\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
                yield u'  ' + line
        yield u'\n'
github googlearchive / appengine-flask-skeleton / lib / werkzeug / contrib / atom.py View on Github external
def _make_text_block(name, content, content_type=None):
    """Helper function for the builder that creates an XML text block."""
    if content_type == 'xhtml':
        return u'&lt;%s type="xhtml"&gt;<div xmlns="%s">%s</div>\n' % \
               (name, XHTML_NAMESPACE, content, name)
    if not content_type:
        return u'&lt;%s&gt;%s\n' % (name, escape(content), name)
    return u'&lt;%s type="%s"&gt;%s\n' % (name, content_type,
                                         escape(content), name)
github limodou / uliweb / uliweb / lib / werkzeug / contrib / atom.py View on Github external
(k, escape(link[k], True)) for k in link)
        for author in self.author:
            yield u'  \n'
            yield u'    %s\n' % escape(author['name'])
            if 'uri' in author:
                yield u'    %s\n' % escape(author['uri'])
            if 'email' in author:
                yield '    %s\n' % escape(author['email'])
            yield '  \n'
        if self.subtitle:
            yield '  ' + _make_text_block('subtitle', self.subtitle,
                                          self.subtitle_type)
        if self.icon:
            yield u'  %s\n' % escape(self.icon)
        if self.logo:
            yield u'  %s\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  %s\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
                yield u'  ' + line
        yield u'\n'
github googlearchive / appengine-flask-skeleton / lib / werkzeug / contrib / atom.py View on Github external
yield '  \n'
        if self.subtitle:
            yield '  ' + _make_text_block('subtitle', self.subtitle,
                                          self.subtitle_type)
        if self.icon:
            yield u'  %s\n' % escape(self.icon)
        if self.logo:
            yield u'  %s\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  %s\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
                yield u'  ' + line
        yield u'\n'
github gae-init / gae-init / main / lib / werkzeug / contrib / atom.py View on Github external
def _make_text_block(name, content, content_type=None):
    """Helper function for the builder that creates an XML text block."""
    if content_type == 'xhtml':
        return u'&lt;%s type="xhtml"&gt;<div xmlns="%s">%s</div>\n' % \
               (name, XHTML_NAMESPACE, content, name)
    if not content_type:
        return u'&lt;%s&gt;%s\n' % (name, escape(content), name)
    return u'&lt;%s type="%s"&gt;%s\n' % (name, content_type,
                                         escape(content), name)
github limodou / uliweb / uliweb / lib / werkzeug / contrib / atom.py View on Github external
self.subtitle_type)
        if self.icon:
            yield u'  %s\n' % escape(self.icon)
        if self.logo:
            yield u'  %s\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  %s\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
                yield u'  ' + line
        yield u'\n'