✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ beluga.o2switch.net ​🇻​♯➤ 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 185.154.139.77 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.84
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/alt/python27/lib/python2.7/site-packages/paste/debug//wdg_validate.py
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
"""
Middleware that tests the validity of all generated HTML using the
`WDG HTML Validator <http://www.htmlhelp.com/tools/validator/>`_
"""

from cStringIO import StringIO
import subprocess
from paste.response import header_value
import re
import cgi

__all__ = ['WDGValidateMiddleware']

class WDGValidateMiddleware(object):

    """
    Middleware that checks HTML and appends messages about the validity of
    the HTML.  Uses: http://www.htmlhelp.com/tools/validator/ -- interacts
    with the command line client.  Use the configuration ``wdg_path`` to
    override the path (default: looks for ``validate`` in $PATH).

    To install, in your web context's __init__.py::

        def urlparser_wrap(environ, start_response, app):
            return wdg_validate.WDGValidateMiddleware(app)(
                environ, start_response)

    Or in your configuration::

        middleware.append('paste.wdg_validate.WDGValidateMiddleware')
    """

    _end_body_regex = re.compile(r'</body>', re.I)

    def __init__(self, app, global_conf=None, wdg_path='validate'):
        self.app = app
        self.wdg_path = wdg_path

    def __call__(self, environ, start_response):
        output = StringIO()
        response = []

        def writer_start_response(status, headers, exc_info=None):
            response.extend((status, headers))
            start_response(status, headers, exc_info)
            return output.write

        app_iter = self.app(environ, writer_start_response)
        try:
            for s in app_iter:
                output.write(s)
        finally:
            if hasattr(app_iter, 'close'):
                app_iter.close()
        page = output.getvalue()
        status, headers = response
        v = header_value(headers, 'content-type') or ''
        if (not v.startswith('text/html')
            and not v.startswith('text/xhtml')
            and not v.startswith('application/xhtml')):
            # Can't validate
            # @@: Should validate CSS too... but using what?
            return [page]
        ops = []
        if v.startswith('text/xhtml+xml'):
            ops.append('--xml')
        # @@: Should capture encoding too
        html_errors = self.call_wdg_validate(
            self.wdg_path, ops, page)
        if html_errors:
            page = self.add_error(page, html_errors)[0]
            headers.remove(
                     ('Content-Length',
                      str(header_value(headers, 'content-length'))))
            headers.append(('Content-Length', str(len(page))))
        return [page]

    def call_wdg_validate(self, wdg_path, ops, page):
        if subprocess is None:
            raise ValueError(
                "This middleware requires the subprocess module from "
                "Python 2.4")
        proc = subprocess.Popen([wdg_path] + ops,
                                shell=False,
                                close_fds=True,
                                stdout=subprocess.PIPE,
                                stdin=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
        stdout = proc.communicate(page)[0]
        proc.wait()
        return stdout

    def add_error(self, html_page, html_errors):
        add_text = ('<pre style="background-color: #ffd; color: #600; '
                    'border: 1px solid #000;">%s</pre>'
                    % cgi.escape(html_errors))
        match = self._end_body_regex.search(html_page)
        if match:
            return [html_page[:match.start()]
                    + add_text
                    + html_page[match.start():]]
        else:
            return [html_page + add_text]

def make_wdg_validate_middleware(
    app, global_conf, wdg_path='validate'):
    """
    Wraps the application in the WDG validator from
    http://www.htmlhelp.com/tools/validator/

    Validation errors are appended to the text of each page.
    You can configure this by giving the path to the validate
    executable (by default picked up from $PATH)
    """
    return WDGValidateMiddleware(
        app, global_conf, wdg_path=wdg_path)


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
25 Jul 2024 8.43 AM
root / linksafe
0755
__init__.py
0.216 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
__init__.pyc
0.219 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
debugapp.py
2.76 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
debugapp.pyc
3.108 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
doctest_webapp.py
14.553 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
doctest_webapp.py.stdlib
14.658 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
doctest_webapp.pyc
14.79 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
fsdiff.py
12.773 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
fsdiff.py.stdlib
12.704 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
fsdiff.pyc
14.078 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
prints.py
5.431 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
prints.pyc
5.417 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
profile.py
7.446 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
profile.pyc
8.466 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
testserver.py
3.306 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
testserver.pyc
4.169 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
watchthreads.py
10.608 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
watchthreads.pyc
11.43 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
wdg_validate.py
4.168 KB
22 Oct 2019 6.09 AM
root / linksafe
0644
wdg_validate.py.stdlib
4.249 KB
21 Dec 2011 5.12 PM
root / linksafe
0644
wdg_validate.pyc
4.497 KB
22 Oct 2019 6.09 AM
root / linksafe
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF