From c04a441b3ee74e40c79e225b80a8ac891c8895ec Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 30 Jun 2010 05:59:17 -0700 Subject: [PATCH] Actually make URI.DisableResources do something. Signed-off-by: Edward Z. Yang --- NEWS | 2 ++ .../ConfigSchema/schema/URI.DisableResources.txt | 7 +++++-- .../HTMLPurifier/URIFilter/DisableResources.php | 11 ++++++++++ .../URIFilter/DisableResourcesTest.php | 24 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 library/HTMLPurifier/URIFilter/DisableResources.php create mode 100644 tests/HTMLPurifier/URIFilter/DisableResourcesTest.php diff --git a/NEWS b/NEWS index 617d6a17..6a7e2a33 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt index 51e6ea91..733e65d6 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt @@ -1,12 +1,15 @@ URI.DisableResources TYPE: bool -VERSION: 1.3.0 +VERSION: 4.1.2 DEFAULT: false --DESCRIPTION-- -

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.

+

+ Note: While this directive has been available since 1.3.0, + it didn't actually start doing anything until 4.1.2. +

--# vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/URIFilter/DisableResources.php b/library/HTMLPurifier/URIFilter/DisableResources.php new file mode 100644 index 00000000..67538c7b --- /dev/null +++ b/library/HTMLPurifier/URIFilter/DisableResources.php @@ -0,0 +1,11 @@ +get('EmbeddedURI', true); + } +} + +// vim: et sw=4 sts=4 diff --git a/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php b/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php new file mode 100644 index 00000000..c2cea8fe --- /dev/null +++ b/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php @@ -0,0 +1,24 @@ +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 -- 2.11.4.GIT