mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 06:07:26 +02:00
Remove trailing whitespace.
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -9,13 +9,13 @@ 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.
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ foreach ($files as $file) {
|
||||
break;
|
||||
}
|
||||
if (!$ok) continue;
|
||||
|
||||
|
||||
$ok = false;
|
||||
for($i++; $i < $c; $i++) {
|
||||
if ($tokens[$i] === ',' || $tokens[$i] === ')' || $tokens[$i] === ';') {
|
||||
@@ -87,46 +87,46 @@ foreach ($files as $file) {
|
||||
}
|
||||
}
|
||||
if (!$ok) continue;
|
||||
|
||||
|
||||
$line = $tokens[$i][2];
|
||||
|
||||
|
||||
consumeWhitespace($tokens, $i);
|
||||
if (!testToken($tokens[$i], T_STRING, 'get')) continue;
|
||||
|
||||
|
||||
consumeWhitespace($tokens, $i);
|
||||
if (!testToken($tokens[$i], '(')) continue;
|
||||
|
||||
|
||||
$full_counter++;
|
||||
|
||||
|
||||
$matched = false;
|
||||
do {
|
||||
|
||||
|
||||
// What we currently don't match are batch retrievals, and
|
||||
// wildcard retrievals. This data might be useful in the future,
|
||||
// which is why we have a do {} while loop that doesn't actually
|
||||
// do anything.
|
||||
|
||||
|
||||
consumeWhitespace($tokens, $i);
|
||||
if (!testToken($tokens[$i], T_CONSTANT_ENCAPSED_STRING)) continue;
|
||||
$namespace = substr($tokens[$i][1], 1, -1);
|
||||
|
||||
|
||||
consumeWhitespace($tokens, $i);
|
||||
if (!testToken($tokens[$i], ',')) continue;
|
||||
|
||||
|
||||
consumeWhitespace($tokens, $i);
|
||||
if (!testToken($tokens[$i], T_CONSTANT_ENCAPSED_STRING)) continue;
|
||||
$directive = substr($tokens[$i][1], 1, -1);
|
||||
|
||||
|
||||
$counter++;
|
||||
$matched = true;
|
||||
|
||||
|
||||
$id = "$namespace.$directive";
|
||||
if (!isset($tracker[$id])) $tracker[$id] = array();
|
||||
if (!isset($tracker[$id][$file])) $tracker[$id][$file] = array();
|
||||
$tracker[$id][$file][] = $line;
|
||||
|
||||
|
||||
} while (0);
|
||||
|
||||
|
||||
//echo "$file:$line uses $namespace.$directive\n";
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ assertCli();
|
||||
* called if changes to any subclasses of HTMLPurifier_Definition
|
||||
* or related classes (such as HTMLPurifier_HTMLModule) are made. This
|
||||
* may also be necessary if you've modified a customized version.
|
||||
*
|
||||
*
|
||||
* @param Accepts one argument, cache type to flush; otherwise flushes all
|
||||
* the caches.
|
||||
*/
|
||||
|
@@ -23,7 +23,7 @@ $exclude_dirs = array(
|
||||
'HTMLPurifier/Filter/',
|
||||
'HTMLPurifier/Printer/',
|
||||
/* These should be excluded, but need to have ConfigSchema support first
|
||||
|
||||
|
||||
*/
|
||||
);
|
||||
$exclude_files = array(
|
||||
@@ -58,7 +58,7 @@ echo "done!\n";
|
||||
|
||||
/**
|
||||
* Returns a lookup array of dependencies for a file.
|
||||
*
|
||||
*
|
||||
* @note This function expects that format $name extends $parent on one line
|
||||
*
|
||||
* @param $file
|
||||
@@ -140,13 +140,13 @@ $php = "<?php
|
||||
* the core files required by HTML Purifier. Use this if performance is a
|
||||
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
|
||||
* FILE, changes will be overwritten the next time the script is run.
|
||||
*
|
||||
*
|
||||
* @version $version
|
||||
*
|
||||
*
|
||||
* @warning
|
||||
* You must *not* include any other HTML Purifier files before this file,
|
||||
* because 'require' not 'require_once' is used.
|
||||
*
|
||||
*
|
||||
* @warning
|
||||
* This file requires that the include path contains the HTML Purifier
|
||||
* library directory; this is not auto-set.
|
||||
@@ -170,7 +170,7 @@ $php = "<?php
|
||||
* the core files required by HTML Purifier. This is a convenience stub that
|
||||
* includes all files using dirname(__FILE__) and require_once. PLEASE DO NOT
|
||||
* EDIT THIS FILE, changes will be overwritten the next time the script is run.
|
||||
*
|
||||
*
|
||||
* Changes to include_path are not necessary.
|
||||
*/
|
||||
|
||||
|
@@ -10,7 +10,7 @@ assertCli();
|
||||
* @file
|
||||
* Generates a schema cache file, saving it to
|
||||
* library/HTMLPurifier/ConfigSchema/schema.ser.
|
||||
*
|
||||
*
|
||||
* This should be run when new configuration options are added to
|
||||
* HTML Purifier. A cached version is available via SVN so this does not
|
||||
* normally have to be regenerated.
|
||||
|
@@ -11,7 +11,7 @@ exit;
|
||||
/**
|
||||
* @file
|
||||
* Removes leading includes from files.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
* This does not remove inline includes; those must be handled manually.
|
||||
*/
|
||||
|
43
maintenance/remove-trailing-whitespace.php
Normal file
43
maintenance/remove-trailing-whitespace.php
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
require_once 'common.php';
|
||||
assertCli();
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Removes trailing whitespace from files.
|
||||
*/
|
||||
|
||||
chdir(dirname(__FILE__) . '/..');
|
||||
$FS = new FSTools();
|
||||
|
||||
function prefix_is($comp, $subject) {
|
||||
return strncmp($comp, $subject, strlen($comp)) === 0;
|
||||
}
|
||||
|
||||
function postfix_is($comp, $subject) {
|
||||
return strlen($subject) < $comp ? false : substr($subject, -strlen($comp)) === $comp;
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
@@ -12,15 +12,15 @@ assertCli();
|
||||
|
||||
class XmlRpc_Freshmeat
|
||||
{
|
||||
|
||||
|
||||
const URL = 'http://freshmeat.net/xmlrpc/';
|
||||
|
||||
|
||||
public $chatty = false;
|
||||
|
||||
|
||||
public $encodeOptions = array(
|
||||
'encoding' => 'utf-8',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* This array defines shortcut method signatures for dealing with simple
|
||||
* XML RPC methods. More complex ones (publish_release) should use the named parameter
|
||||
@@ -32,9 +32,9 @@ class XmlRpc_Freshmeat
|
||||
'fetch_release' => array('project_name', 'branch_name', 'version'),
|
||||
'withdraw_release' => array('project_name', 'branch_name', 'version'),
|
||||
);
|
||||
|
||||
|
||||
protected $sid = null;
|
||||
|
||||
|
||||
/**
|
||||
* @param $username Username to login with
|
||||
* @param $password Password to login with
|
||||
@@ -44,13 +44,13 @@ class XmlRpc_Freshmeat
|
||||
$this->login($username, $password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs a raw XML RPC call to self::URL
|
||||
*/
|
||||
protected function call($method, $params) {
|
||||
$request = xmlrpc_encode_request($method, $params, $this->encodeOptions);
|
||||
$ch = curl_init();
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, self::URL);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
|
||||
@@ -59,7 +59,7 @@ class XmlRpc_Freshmeat
|
||||
'Content-length: ' . strlen($request)
|
||||
));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
||||
$data = curl_exec($ch);
|
||||
$data = curl_exec($ch);
|
||||
if ($errno = curl_errno($ch)) {
|
||||
throw new Exception("Curl error [$errno]: " . curl_error($ch));
|
||||
} else {
|
||||
@@ -67,7 +67,7 @@ class XmlRpc_Freshmeat
|
||||
return xmlrpc_decode($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs an XML RPC call to Freshmeat.
|
||||
* @param $name Name of method to call, can be methodName or method_name
|
||||
@@ -98,7 +98,7 @@ class XmlRpc_Freshmeat
|
||||
if ($this->chatty) print_r($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Munge methodName to method_name
|
||||
*/
|
||||
@@ -111,14 +111,14 @@ class XmlRpc_Freshmeat
|
||||
}
|
||||
return $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Automatically logout at end of scope
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->sid) $this->logout();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$rpc = new XmlRpc_Freshmeat($argv[1], $argv[2]);
|
||||
|
Reference in New Issue
Block a user