require_once 'common.php';
require_once '../library/HTMLPurifier.auto.php';
assertCli();
if (version_compare(PHP_VERSION, '5.2.2', '<')) {
    echo "This script requires PHP 5.2.2 or later, for tokenizer line numbers.";
    exit(1);
}
/**
 * @file
 * Scans HTML Purifier source code for $config tokens and records the
 * directive being used; configdoc can use this info later.
 *
 * Currently, this just dumps all the info onto the console. Eventually, it
 * will create an XML file that our XSLT transform can use.
 */
$FS = new FSTools();
chdir(dirname(__FILE__) . '/../library/');
$raw_files = $FS->globr('.', '*.php');
$files = array();
foreach ($raw_files as $file) {
    $file = substr($file, 2);
    // rm leading './'
    if (strncmp('standalone/', $file, 11) === 0) {
        continue;
    }
    // rm generated files
    if (substr_count($file, '.') > 1) {
        continue;
    }
    // rm meta files
    $files[] = $file;
Example #2
0
 /**
  * Filename of file you wish to instantiate.
  * @note This file need not exist
  */
 public function __construct($name, $fs = false)
 {
     $this->name = $name;
     $this->fs = $fs ? $fs : FSTools::singleton();
 }
Example #3
0
#!/usr/bin/php
<?php 
chdir(dirname(__FILE__));
require_once 'common.php';
assertCli();
echo "Please do not run this script. It is here for historical purposes only.";
exit;
/**
 * @file
 * Removes ConfigSchema function calls from source files.
 */
chdir(dirname(__FILE__) . '/../library/');
$FS = new FSTools();
$files = $FS->globr('.', '*info.php');
foreach ($files as $file) {
    if (substr_count(basename($file), '.') > 1) {
        continue;
    }
    $old_code = file_get_contents($file);
    $new_code = preg_replace("#^HTMLPurifier_ConfigSchema::.+?\\);[\n\r]*#ms", '', $old_code);
    if ($old_code !== $new_code) {
        file_put_contents($file, $new_code);
    }
    if (preg_match('#^\\s+HTMLPurifier_ConfigSchema::#m', $new_code)) {
        echo "Indented ConfigSchema call in {$file}\n";
    }
}
// vim: et sw=4 sts=4
#!/usr/bin/php
<?php 
chdir(dirname(__FILE__));
require_once 'common.php';
assertCli();
/**
 * @file
 * Adds vimline to files
 */
chdir(dirname(__FILE__) . '/..');
$FS = new FSTools();
$vimline = 'vim: et sw=4 sts=4';
$files = $FS->globr('.', '*');
foreach ($files as $file) {
    if (!is_file($file) || prefix_is('./docs/doxygen', $file) || prefix_is('./library/standalone', $file) || prefix_is('./docs/specimens', $file) || postfix_is('.ser', $file) || postfix_is('.tgz', $file) || postfix_is('.patch', $file) || postfix_is('.dtd', $file) || postfix_is('.ent', $file) || postfix_is('.png', $file) || postfix_is('.ico', $file) || postfix_is('.vtest', $file) || postfix_is('.svg', $file) || postfix_is('.phpt', $file) || postfix_is('VERSION', $file) || postfix_is('WHATSNEW', $file) || postfix_is('configdoc/usage.xml', $file) || postfix_is('library/HTMLPurifier.includes.php', $file) || postfix_is('library/HTMLPurifier.safe-includes.php', $file) || postfix_is('smoketests/xssAttacks.xml', $file) || postfix_is('.diff', $file) || postfix_is('.exp', $file) || postfix_is('.log', $file) || postfix_is('.out', $file) || $file == './library/HTMLPurifier/Lexer/PH5P.php' || $file == './maintenance/PH5P.php') {
        continue;
    }
    $ext = strrchr($file, '.');
    if (postfix_is('README', $file) || postfix_is('LICENSE', $file) || postfix_is('CREDITS', $file) || postfix_is('INSTALL', $file) || postfix_is('NEWS', $file) || postfix_is('TODO', $file) || postfix_is('WYSIWYG', $file) || postfix_is('Changelog', $file)) {
        $ext = '.txt';
    }
    if (postfix_is('Doxyfile', $file)) {
        $ext = 'Doxyfile';
    }
    if (postfix_is('.php.in', $file)) {
        $ext = '.php';
    }
    $no_nl = false;
    switch ($ext) {
        case '.php':
        case '.inc':
Example #5
0
 /**
  * Sets our global singleton to something else; useful for overloading
  * functions.
  */
 public static function setSingleton($singleton)
 {
     FSTools::$singleton = $singleton;
 }
Example #6
0
}
if ($AC['flush']) {
    htmlpurifier_flush($AC['php'], $reporter);
}
// Now, userland code begins to be executed
// setup special DefinitionCacheFactory decorator
$factory = HTMLPurifier_DefinitionCacheFactory::instance();
$factory->addDecorator('Memory');
// since we deal with a lot of config objects
if (!$AC['disable-phpt']) {
    $phpt = PHPT_Registry::getInstance();
    $phpt->php = $AC['php'];
}
// load tests
require 'test_files.php';
$FS = new FSTools();
// handle test dirs
foreach ($test_dirs as $dir) {
    $raw_files = $FS->globr($dir, '*Test.php');
    foreach ($raw_files as $file) {
        $file = str_replace('\\', '/', $file);
        if (isset($test_dirs_exclude[$file])) {
            continue;
        }
        $test_files[] = $file;
    }
}
// handle vtest dirs
foreach ($vtest_dirs as $dir) {
    $raw_files = $FS->globr($dir, '*.vtest');
    foreach ($raw_files as $file) {
 function __destruct()
 {
     FSTools::singleton()->rmdirr($this->dir);
 }
#!/usr/bin/php
<?php 
chdir(dirname(__FILE__));
require_once 'common.php';
assertCli();
/**
 * @file
 * Removes trailing whitespace from files.
 */
chdir(dirname(__FILE__) . '/..');
$FS = new FSTools();
$files = $FS->globr('.', '{,.}*', GLOB_BRACE);
foreach ($files as $file) {
    if (!is_file($file) || prefix_is('./.git', $file) || prefix_is('./docs/doxygen', $file) || postfix_is('.ser', $file) || postfix_is('.tgz', $file) || postfix_is('.patch', $file) || postfix_is('.dtd', $file) || postfix_is('.ent', $file) || $file == './library/HTMLPurifier/Lexer/PH5P.php' || $file == './maintenance/PH5P.php') {
        continue;
    }
    $contents = file_get_contents($file);
    $result = preg_replace('/^(.*?)[ \\t]+(\\r?)$/m', '\\1\\2', $contents, -1, $count);
    if (!$count) {
        continue;
    }
    echo "{$file}\n";
    file_put_contents($file, $result);
}
// vim: et sw=4 sts=4