Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.129.216.70
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/python-libxslt1/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/doc/python-libxslt1/examples/extelem.py
#!/usr/bin/python -u
import sys
import string
import StringIO
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
import libxslt

EXT_URL="http://example.com/foo"

insertNodeName = None
transformNodeName = None

def compile_test(style, inst, func):
    pass

def transform_test(ctx, node, inst, comp):
    global insertNodeName

    #
    # Small check to verify the context is correcly accessed
    #
    try:
        #
        # FIXME add some more sanity checks
        #
        tctxt = libxslt.transformCtxt(_obj=ctx)
        insertNodeName = tctxt.insertNode().name

        # FIXME find and confirm the note being replaced is called 'test'
        # transformNodeName = libxml2.xmlNode(inst).name
    except:
        pass

    tctxt.insertNode().addContent('SUCCESS')
    


styledoc = libxml2.parseDoc("""
<xsl:stylesheet version='1.0'
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:foo='%s'
  extension-element-prefixes='foo'>

  <xsl:template match='/'>
    <article><foo:test>FAILURE</foo:test></article>
    <deeper><article><foo:test>something<foo:test>nested</foo:test>even</foo:test></article></deeper>
  </xsl:template>
</xsl:stylesheet>
""" % EXT_URL)

style = libxslt.parseStylesheetDoc(styledoc)
libxslt.registerExtModuleElement("test", EXT_URL, compile_test, transform_test)
doc = libxml2.parseDoc("<doc/>")
result = style.applyStylesheet(doc, None)
style.freeStylesheet()
doc.freeDoc()


extensions = StringIO.StringIO()
libxslt.debugDumpExtensions(extensions)

if 0 and extensions.buf.find(EXT_URL) < 0:
    print "Element extension not registered (or dumping broken)"
    sys.exit(1)

root = result.children

if root.name != "article":
    print "Unexpected root node name"
    sys.exit(1)
if root.content != "SUCCESS":
    print "Unexpected root node content, extension function failed"
    sys.exit(1)
if insertNodeName != 'article':
    print "The function callback failed to access its context"
    sys.exit(1)

result.dump(sys.stdout)
result.freeDoc()

# Memory debug specific
libxslt.cleanup()
if libxml2.debugMemory(1) == 0:
    print "OK"
else:
    print "Memory leak %d bytes" % (libxml2.debugMemory(1))
    libxml2.dumpMemory()

Anon7 - 2022
AnonSec Team