From 7c91104532484b0ba9f92f20b6a37aa160538cca Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 8 Sep 2010 23:39:20 -0400 Subject: [PATCH] Implement HTML.FlashAllowFullScreen. Signed-off-by: Edward Z. Yang --- NEWS | 2 ++ configdoc/usage.xml | 5 +++++ library/HTMLPurifier/AttrTransform/SafeParam.php | 7 +++++++ library/HTMLPurifier/ConfigSchema/schema.ser | Bin 13488 -> 13599 bytes .../ConfigSchema/schema/Filter.YouTube.txt | 5 +++++ .../schema/HTML.FlashAllowFullScreen.txt | 11 +++++++++++ library/HTMLPurifier/Injector/SafeObject.php | 1 + tests/HTMLPurifier/HTMLModule/SafeObjectTest.php | 10 ++++++++-- 8 files changed, 39 insertions(+), 2 deletions(-) rewrite library/HTMLPurifier/ConfigSchema/schema.ser (78%) create mode 100644 library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt diff --git a/NEWS b/NEWS index 6bc8a962..90497358 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier did nothing. Thanks David Rothstein for reporting. ! Add documentation about configuration directive types. ! Add %CSS.ForbiddenProperties configuration directive. +! Add %HTML.FlashAllowFullScreen to permit embedded Flash objects + to utilize full-screen mode. - Fix improper handling of Internet Explorer conditional comments by parser. Thanks zmonteca for reporting. - Fix missing attributes bug when running on Mac Snow Leopard and APC. diff --git a/configdoc/usage.xml b/configdoc/usage.xml index 4086092d..a8c465db 100644 --- a/configdoc/usage.xml +++ b/configdoc/usage.xml @@ -347,6 +347,11 @@ 13 + + + 37 + + 62 diff --git a/library/HTMLPurifier/AttrTransform/SafeParam.php b/library/HTMLPurifier/AttrTransform/SafeParam.php index 3f992ec3..d378c4f5 100644 --- a/library/HTMLPurifier/AttrTransform/SafeParam.php +++ b/library/HTMLPurifier/AttrTransform/SafeParam.php @@ -33,6 +33,13 @@ class HTMLPurifier_AttrTransform_SafeParam extends HTMLPurifier_AttrTransform case 'allowNetworking': $attr['value'] = 'internal'; break; + case 'allowFullScreen': + if ($config->get('HTML.FlashAllowFullScreen')) { + $attr['value'] = ($attr['value'] == 'true') ? 'true' : 'false'; + } else { + $attr['value'] = 'false'; + } + break; case 'wmode': $attr['value'] = 'window'; break; diff --git a/library/HTMLPurifier/ConfigSchema/schema.ser b/library/HTMLPurifier/ConfigSchema/schema.ser dissimilarity index 78% index 20bd89dfbf1dd388bc5bd10d24f9ef875f45d767..2d7cfa1ac4a68508920c6b1c5c12bc9b864d5188 100644 GIT binary patch delta 160 zcwXC(IX`QHIivC9i3+ltdj(p!6-}*_JVJbZ^xSe1i!&T^a`MaFN^^38lZ#SQ^OUTU qtPD2u$^@}YRu}LfRaY|$quJ((3VwV9RA*Y5Pv(_T-26vx3o8I^>@-UN delta 52 xcwU>IwIOqYIiu0!+X}K9LtD5v|KpycLkkNGWZ3RER&3^h9Spg^f6bAqR diff --git a/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt b/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt index 7fa6536b..321eaa2d 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt @@ -4,6 +4,11 @@ VERSION: 3.1.0 DEFAULT: false --DESCRIPTION--

+ Warning: Deprecated in favor of %HTML.SafeObject and + %Output.FlashCompat (turn both on to allow YouTube videos and other + Flash content). +

+

This directive enables YouTube video embedding in HTML Purifier. Check this document on embedding videos for more information on what this filter does. diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt new file mode 100644 index 00000000..dd6d457c --- /dev/null +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt @@ -0,0 +1,11 @@ +HTML.FlashAllowFullScreen +TYPE: bool +VERSION: 4.1.2 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit embedded Flash content from + %HTML.SafeObject to expand to the full screen. Corresponds to + the allowFullScreen parameter. +

+--# vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/Injector/SafeObject.php b/library/HTMLPurifier/Injector/SafeObject.php index 9e178ce0..c1d8b041 100644 --- a/library/HTMLPurifier/Injector/SafeObject.php +++ b/library/HTMLPurifier/Injector/SafeObject.php @@ -22,6 +22,7 @@ class HTMLPurifier_Injector_SafeObject extends HTMLPurifier_Injector 'movie' => true, 'flashvars' => true, 'src' => true, + 'allowFullScreen' => true, // if omitted, assume to be 'false' ); public function prepare($config, $context) { diff --git a/tests/HTMLPurifier/HTMLModule/SafeObjectTest.php b/tests/HTMLPurifier/HTMLModule/SafeObjectTest.php index 667a8a83..d8a23d50 100644 --- a/tests/HTMLPurifier/HTMLModule/SafeObjectTest.php +++ b/tests/HTMLPurifier/HTMLModule/SafeObjectTest.php @@ -6,8 +6,7 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn function setUp() { parent::setUp(); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest'); - $def = $this->config->getHTMLDefinition(true); - $def->manager->addModule('SafeObject'); + $this->config->set('HTML.SafeObject', true); } function testMinimal() { @@ -38,6 +37,13 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn ); } + function testFullScreen() { + $this->config->set('HTML.FlashAllowFullScreen', true); + $this->assertResult( + '' + ); + } + } // vim: et sw=4 sts=4 -- 2.11.4.GIT