0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 15:28:40 +00:00

Actually make URI.DisableResources do something.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2010-06-30 05:59:17 -07:00
parent 1bed8b6d5f
commit c04a441b3e
4 changed files with 42 additions and 2 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
4.1.2, unknown release date
! Added %Core.RemoveProcessingInstructions, which lets you remove
<? ... ?> statements.
! Added %URI.DisableResources functionality; the directive originally
did nothing. Thanks David Rothstein for reporting.
- Fix improper handling of Internet Explorer conditional comments
by parser. Thanks zmonteca for reporting.

View File

@ -1,12 +1,15 @@
URI.DisableResources
TYPE: bool
VERSION: 1.3.0
VERSION: 4.1.2
DEFAULT: false
--DESCRIPTION--
<p>
Disables embedding resources, essentially meaning no pictures. You can
still link to them though. See %URI.DisableExternalResources for why
this might be a good idea.
</p>
<p>
<em>Note:</em> While this directive has been available since 1.3.0,
it didn't actually start doing anything until 4.1.2.
</p>
--# vim: et sw=4 sts=4

View File

@ -0,0 +1,11 @@
<?php
class HTMLPurifier_URIFilter_DisableResources extends HTMLPurifier_URIFilter
{
public $name = 'DisableResources';
public function filter(&$uri, $config, $context) {
return !$context->get('EmbeddedURI', true);
}
}
// vim: et sw=4 sts=4

View File

@ -0,0 +1,24 @@
<?php
class HTMLPurifier_URIFilter_DisableResourcesTest extends HTMLPurifier_URIFilterHarness
{
function setUp() {
parent::setUp();
$this->filter = new HTMLPurifier_URIFilter_DisableResources();
$var = true;
$this->context->register('EmbeddedURI', $var);
}
function testRemoveResource() {
$this->assertFiltering('/foo/bar', false);
}
function testPreserveRegular() {
$this->context->destroy('EmbeddedURI'); // undo setUp
$this->assertFiltering('/foo/bar');
}
}
// vim: et sw=4 sts=4