mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 13:47:24 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6bc04e0e10 | ||
|
24f6db6fb2 | ||
|
85fb192d93 | ||
|
7727cea112 | ||
|
6bb8c1fcac | ||
|
a84b6d5be0 | ||
|
6e43cac9c9 | ||
|
656a0c95bf |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
configdoc/usage.xml -crlf
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
conf/
|
||||
library/HTMLPurifier/DefinitionCache/Serializer/*/
|
||||
library/standalone/
|
||||
library/HTMLPurifier.standalone.php
|
||||
*.phpt.diff
|
||||
*.phpt.exp
|
||||
*.phpt.log
|
||||
*.phpt.out
|
||||
*.phpt.php
|
13
FOCUS
Normal file
13
FOCUS
Normal file
@@ -0,0 +1,13 @@
|
||||
9 - Major security fixes
|
||||
|
||||
[ Appendix A: Release focus IDs ]
|
||||
0 - N/A
|
||||
1 - Initial freshmeat announcement
|
||||
2 - Documentation
|
||||
3 - Code cleanup
|
||||
4 - Minor feature enhancements
|
||||
5 - Major feature enhancements
|
||||
6 - Minor bugfixes
|
||||
7 - Major bugfixes
|
||||
8 - Minor security fixes
|
||||
9 - Major security fixes
|
6
NEWS
6
NEWS
@@ -9,6 +9,12 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
. Internal change
|
||||
==========================
|
||||
|
||||
3.2.0, unknown release date
|
||||
|
||||
3.1.2, unknown release date
|
||||
! %Output.AttrSort for when you need your attributes in alphabetical order to
|
||||
deal with a bug in FCKEditor. Requested by frank farmer.
|
||||
|
||||
3.1.1, released 2008-06-19
|
||||
# %URI.Munge now, by default, does not munge resources (for example, <img src="">)
|
||||
In order to enable this again, please set %URI.MungeResources to true.
|
||||
|
5
WHATSNEW
5
WHATSNEW
@@ -2,8 +2,7 @@ HTML Purifier 3.1.1 is a security and bugfix release. This release addresses
|
||||
two security vulnerabilities, both related to CSS, and one of which only
|
||||
applies to users using Shift_JIS as their output encoding. There is also
|
||||
a security improvement regarding the imagecrash attack. There is a backwards
|
||||
incompatible change with %URI.Munge, in which resources are no longer munged
|
||||
incompatible change in which resources are no longer munged
|
||||
by default; please enable using %URI.MungeResources. Besides this, there
|
||||
are numerous improvements to URI munging, esp. with the addition of
|
||||
%URI.MungeSecretKey, as well as an experimental implementation of
|
||||
%HTML.SafeObject and %HTML.SafeEmbed. There are also some memory optimizations.
|
||||
%URI.MungeSecretKey, as well as an experimental %HTML.SafeObject and %HTML.SafeEmbed.
|
||||
|
@@ -96,17 +96,22 @@
|
||||
</directive>
|
||||
<directive id="Output.CommentScriptContents">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>40</line>
|
||||
<line>45</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.SortAttr">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>46</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.TidyFormat">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>69</line>
|
||||
<line>75</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.Newline">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>83</line>
|
||||
<line>89</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="HTML.BlockWrapper">
|
||||
|
@@ -118,9 +118,8 @@ there are now many character encodings floating around.</p>
|
||||
see a page on the web, chances are it's encoded in one
|
||||
of these encodings.</li>
|
||||
<li><strong>Unicode-based encodings</strong> implement the
|
||||
Unicode standard and include UTF-8, UCS-2 and UTF-16.
|
||||
They go beyond 8-bits (the first two are variable length,
|
||||
while the second one uses 16-bits), and support almost
|
||||
Unicode standard and include UTF-8, UTF-16 and UTF-32/UCS-4.
|
||||
They go beyond 8-bits and support almost
|
||||
every language in the world. UTF-8 is gaining traction
|
||||
as the dominant international encoding of the web.</li>
|
||||
</ul>
|
||||
|
File diff suppressed because one or more lines are too long
13
library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt
Normal file
13
library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
Output.SortAttr
|
||||
TYPE: bool
|
||||
VERSION: 3.1.2
|
||||
DEFAULT: false
|
||||
--DESCRIPTION--
|
||||
<p>
|
||||
If true, HTML Purifier will sort attributes by name before writing them back
|
||||
to the document, converting a tag like: <code><el b="" a="" c="" /></code>
|
||||
to <code><el a="" b="" c="" /></code>. This is a workaround for
|
||||
a bug in FCKeditor which causes it to swap attributes order, adding noise
|
||||
to text diffs. If you're not seeing this bug, chances are, you don't need
|
||||
this directive.
|
||||
</p>
|
1
library/HTMLPurifier/DefinitionCache/Serializer/README
Normal file
1
library/HTMLPurifier/DefinitionCache/Serializer/README
Normal file
@@ -0,0 +1 @@
|
||||
This is a dummy file to prevent Git from ignoring this empty directory.
|
@@ -26,6 +26,11 @@ class HTMLPurifier_Generator
|
||||
*/
|
||||
private $_def;
|
||||
|
||||
/**
|
||||
* Cache of %Output.SortAttr
|
||||
*/
|
||||
private $_sortAttr;
|
||||
|
||||
/**
|
||||
* Configuration for the generator
|
||||
*/
|
||||
@@ -38,6 +43,7 @@ class HTMLPurifier_Generator
|
||||
public function __construct($config, $context) {
|
||||
$this->config = $config;
|
||||
$this->_scriptFix = $config->get('Output', 'CommentScriptContents');
|
||||
$this->_sortAttr = $config->get('Output', 'SortAttr');
|
||||
$this->_def = $config->getHTMLDefinition();
|
||||
$this->_xhtml = $this->_def->doctype->xml;
|
||||
}
|
||||
@@ -142,6 +148,7 @@ class HTMLPurifier_Generator
|
||||
*/
|
||||
public function generateAttributes($assoc_array_of_attributes, $element = false) {
|
||||
$html = '';
|
||||
if ($this->_sortAttr) ksort($assoc_array_of_attributes);
|
||||
foreach ($assoc_array_of_attributes as $key => $value) {
|
||||
if (!$this->_xhtml) {
|
||||
// Remove namespaced attributes
|
||||
|
154
maintenance/update-freshmeat.php
Normal file
154
maintenance/update-freshmeat.php
Normal file
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
require_once 'common.php';
|
||||
assertCli();
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Updates Freshmeat's HTML Purifier with the latest information via XML RPC.
|
||||
*/
|
||||
|
||||
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
|
||||
* syntax.
|
||||
*/
|
||||
public $signatures = array(
|
||||
'login' => array('username', 'password'),
|
||||
'fetch_branch_list' => array('project_name'),
|
||||
'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
|
||||
*/
|
||||
public function __construct($username = null, $password = null) {
|
||||
if ($username && $password) {
|
||||
$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();
|
||||
curl_setopt($ch, CURLOPT_URL, self::URL);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type: text/xml',
|
||||
'Content-length: ' . strlen($request)
|
||||
));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
||||
$data = curl_exec($ch);
|
||||
if ($errno = curl_errno($ch)) {
|
||||
throw new Exception("Curl error [$errno]: " . curl_error($ch));
|
||||
} else {
|
||||
curl_close($ch);
|
||||
return xmlrpc_decode($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an XML RPC call to Freshmeat.
|
||||
* @param $name Name of method to call, can be methodName or method_name
|
||||
* @param $args Arguments of call, in form array('key1', 'val1', 'key2' ...)
|
||||
*/
|
||||
public function __call($name, $args) {
|
||||
$method = $this->camelToUnderscore($name);
|
||||
$params = array();
|
||||
if ($this->sid) $params['SID'] = $this->sid;
|
||||
if (isset($this->signatures[$method])) {
|
||||
for ($i = 0, $c = count($this->signatures[$method]); $i < $c; $i++) {
|
||||
$params[$this->signatures[$method][$i]] = $args[$i];
|
||||
}
|
||||
} else {
|
||||
for ($i = 0, $c = count($args); $i + 1 < $c; $i += 2) {
|
||||
$params[$args[$i]] = $args[$i + 1];
|
||||
}
|
||||
}
|
||||
$result = $this->call($method, $params);
|
||||
switch ($method) {
|
||||
case 'login':
|
||||
$this->sid = $result['SID'];
|
||||
break;
|
||||
case 'logout':
|
||||
$this->sid = null;
|
||||
break;
|
||||
}
|
||||
if ($this->chatty) print_r($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Munge methodName to method_name
|
||||
*/
|
||||
private function camelToUnderscore($name) {
|
||||
$method = '';
|
||||
for ($i = 0, $c = strlen($name); $i < $c; $i++) {
|
||||
$v = $name[$i];
|
||||
if (ctype_lower($v)) $method .= $v;
|
||||
else $method .= '_' . strtolower($v);
|
||||
}
|
||||
return $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically logout at end of scope
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->sid) $this->logout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rpc = new XmlRpc_Freshmeat($argv[1], $argv[2]);
|
||||
$rpc->chatty = true;
|
||||
|
||||
$project = 'htmlpurifier';
|
||||
$branch = 'Default';
|
||||
$version = file_get_contents('../VERSION');
|
||||
|
||||
$result = $rpc->fetchRelease($project, $branch, $version);
|
||||
if (!isset($result['faultCode'])) {
|
||||
echo "Freshmeat release already exists.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$changes = strtr(file_get_contents('../WHATSNEW'), array("\r" => '', "\n" => ' '));
|
||||
$focus = (int) trim(file_get_contents('../FOCUS'));
|
||||
|
||||
if (strlen($changes) > 600) {
|
||||
echo "WHATSNEW entry is too long.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$rpc->publishRelease(
|
||||
'project_name', $project,
|
||||
'branch_name', $branch,
|
||||
'version', $version,
|
||||
'changes', $changes,
|
||||
'release_focus', $focus,
|
||||
'url_tgz', "http://htmlpurifier.org/releases/htmlpurifier-$version.tar.gz",
|
||||
'url_zip', "http://htmlpurifier.org/releases/htmlpurifier-$version.zip",
|
||||
'url_changelog', "http://htmlpurifier.org/svnroot/htmlpurifier/tags/$version/NEWS"
|
||||
);
|
@@ -104,5 +104,5 @@ file_put_contents('library/HTMLPurifier/Config.php', $config_c);
|
||||
|
||||
passthru('php maintenance/flush.php');
|
||||
|
||||
if ($is_dev) echo "Review changes, write something in WHATSNEW, and then SVN commit with log 'Release $version.'" . PHP_EOL;
|
||||
if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then SVN commit with log 'Release $version.'" . PHP_EOL;
|
||||
else echo "Numbers updated to dev, no other modifications necessary!";
|
||||
|
1
tests/HTMLPurifier/DefinitionCache/SerializerTest/README
Normal file
1
tests/HTMLPurifier/DefinitionCache/SerializerTest/README
Normal file
@@ -0,0 +1 @@
|
||||
This is a dummy file to prevent Git from ignoring this empty directory.
|
@@ -209,7 +209,6 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
}
|
||||
|
||||
function test_generateFromTokens_XHTMLoff() {
|
||||
$this->config = HTMLPurifier_Config::createDefault();
|
||||
$this->config->set('HTML', 'XHTML', false);
|
||||
|
||||
// omit trailing slash
|
||||
@@ -237,7 +236,6 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
// just don't test; Tidy is exploding on me.
|
||||
return;
|
||||
|
||||
$this->config = HTMLPurifier_Config::createDefault();
|
||||
$this->config->set('Core', 'TidyFormat', true);
|
||||
$this->config->set('Output', 'Newline', "\n");
|
||||
|
||||
@@ -253,5 +251,15 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function test_generateFromTokens_sortAttr() {
|
||||
$this->config->set('Output', 'SortAttr', true);
|
||||
|
||||
$this->assertGeneration(
|
||||
array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ),
|
||||
'<p a="d" b="c">'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
1
tests/tmp/README
Normal file
1
tests/tmp/README
Normal file
@@ -0,0 +1 @@
|
||||
This is a dummy file to prevent Git from ignoring this empty directory.
|
Reference in New Issue
Block a user