@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | 'debug' => false, |
| 43 | 43 | 'elements' => [ |
| 44 | 44 | // http://developers.whatwg.org/sections.html |
| 45 | - ['section', 'Block', 'Flow', 'Common'], |
|
| 46 | - ['nav', 'Block', 'Flow', 'Common'], |
|
| 47 | - ['article', 'Block', 'Flow', 'Common'], |
|
| 48 | - ['aside', 'Block', 'Flow', 'Common'], |
|
| 49 | - ['header', 'Block', 'Flow', 'Common'], |
|
| 50 | - ['footer', 'Block', 'Flow', 'Common'], |
|
| 45 | + [ 'section', 'Block', 'Flow', 'Common' ], |
|
| 46 | + [ 'nav', 'Block', 'Flow', 'Common' ], |
|
| 47 | + [ 'article', 'Block', 'Flow', 'Common' ], |
|
| 48 | + [ 'aside', 'Block', 'Flow', 'Common' ], |
|
| 49 | + [ 'header', 'Block', 'Flow', 'Common' ], |
|
| 50 | + [ 'footer', 'Block', 'Flow', 'Common' ], |
|
| 51 | 51 | |
| 52 | 52 | // Content model actually excludes several tags, not modelled here |
| 53 | - ['address', 'Block', 'Flow', 'Common'], |
|
| 54 | - ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'], |
|
| 53 | + [ 'address', 'Block', 'Flow', 'Common' ], |
|
| 54 | + [ 'hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common' ], |
|
| 55 | 55 | |
| 56 | 56 | // http://developers.whatwg.org/grouping-content.html |
| 57 | - ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'], |
|
| 58 | - ['figcaption', 'Inline', 'Flow', 'Common'], |
|
| 57 | + [ 'figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common' ], |
|
| 58 | + [ 'figcaption', 'Inline', 'Flow', 'Common' ], |
|
| 59 | 59 | |
| 60 | 60 | // http://developers.whatwg.org/the-video-element.html#the-video-element |
| 61 | - ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ |
|
| 61 | + [ 'video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ |
|
| 62 | 62 | 'src' => 'URI', |
| 63 | 63 | 'type' => 'Text', |
| 64 | 64 | 'width' => 'Length', |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | 'poster' => 'URI', |
| 67 | 67 | 'preload' => 'Enum#auto,metadata,none', |
| 68 | 68 | 'controls' => 'Bool', |
| 69 | - ]], |
|
| 70 | - ['source', 'Block', 'Flow', 'Common', [ |
|
| 69 | + ] ], |
|
| 70 | + [ 'source', 'Block', 'Flow', 'Common', [ |
|
| 71 | 71 | 'src' => 'URI', |
| 72 | 72 | 'type' => 'Text', |
| 73 | - ]], |
|
| 73 | + ] ], |
|
| 74 | 74 | |
| 75 | 75 | // http://developers.whatwg.org/text-level-semantics.html |
| 76 | - ['s', 'Inline', 'Inline', 'Common'], |
|
| 77 | - ['var', 'Inline', 'Inline', 'Common'], |
|
| 78 | - ['sub', 'Inline', 'Inline', 'Common'], |
|
| 79 | - ['sup', 'Inline', 'Inline', 'Common'], |
|
| 80 | - ['mark', 'Inline', 'Inline', 'Common'], |
|
| 81 | - ['wbr', 'Inline', 'Empty', 'Core'], |
|
| 76 | + [ 's', 'Inline', 'Inline', 'Common' ], |
|
| 77 | + [ 'var', 'Inline', 'Inline', 'Common' ], |
|
| 78 | + [ 'sub', 'Inline', 'Inline', 'Common' ], |
|
| 79 | + [ 'sup', 'Inline', 'Inline', 'Common' ], |
|
| 80 | + [ 'mark', 'Inline', 'Inline', 'Common' ], |
|
| 81 | + [ 'wbr', 'Inline', 'Empty', 'Core' ], |
|
| 82 | 82 | |
| 83 | 83 | // http://developers.whatwg.org/edits.html |
| 84 | - ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], |
|
| 85 | - ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], |
|
| 84 | + [ 'ins', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ], |
|
| 85 | + [ 'del', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ], |
|
| 86 | 86 | ], |
| 87 | 87 | 'attributes' => [ |
| 88 | - ['iframe', 'allowfullscreen', 'Bool'], |
|
| 89 | - ['table', 'height', 'Text'], |
|
| 90 | - ['td', 'border', 'Text'], |
|
| 91 | - ['th', 'border', 'Text'], |
|
| 92 | - ['tr', 'width', 'Text'], |
|
| 93 | - ['tr', 'height', 'Text'], |
|
| 94 | - ['tr', 'border', 'Text'], |
|
| 88 | + [ 'iframe', 'allowfullscreen', 'Bool' ], |
|
| 89 | + [ 'table', 'height', 'Text' ], |
|
| 90 | + [ 'td', 'border', 'Text' ], |
|
| 91 | + [ 'th', 'border', 'Text' ], |
|
| 92 | + [ 'tr', 'width', 'Text' ], |
|
| 93 | + [ 'tr', 'height', 'Text' ], |
|
| 94 | + [ 'tr', 'border', 'Text' ], |
|
| 95 | 95 | ], |
| 96 | 96 | ], |
| 97 | 97 | 'custom_attributes' => [ |
| 98 | - ['a', 'target', 'Enum#_blank,_self,_target,_top'], |
|
| 98 | + [ 'a', 'target', 'Enum#_blank,_self,_target,_top' ], |
|
| 99 | 99 | ], |
| 100 | 100 | 'custom_elements' => [ |
| 101 | - ['u', 'Inline', 'Inline', 'Common'], |
|
| 101 | + [ 'u', 'Inline', 'Inline', 'Common' ], |
|
| 102 | 102 | ], |
| 103 | 103 | ], |
| 104 | 104 | |
@@ -49,30 +49,30 @@ discard block |
||
| 49 | 49 | ['header', 'Block', 'Flow', 'Common'], |
| 50 | 50 | ['footer', 'Block', 'Flow', 'Common'], |
| 51 | 51 | |
| 52 | - // Content model actually excludes several tags, not modelled here |
|
| 52 | + // Content model actually excludes several tags, not modelled here |
|
| 53 | 53 | ['address', 'Block', 'Flow', 'Common'], |
| 54 | 54 | ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'], |
| 55 | 55 | |
| 56 | - // http://developers.whatwg.org/grouping-content.html |
|
| 56 | + // http://developers.whatwg.org/grouping-content.html |
|
| 57 | 57 | ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'], |
| 58 | 58 | ['figcaption', 'Inline', 'Flow', 'Common'], |
| 59 | 59 | |
| 60 | - // http://developers.whatwg.org/the-video-element.html#the-video-element |
|
| 60 | + // http://developers.whatwg.org/the-video-element.html#the-video-element |
|
| 61 | 61 | ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ |
| 62 | 62 | 'src' => 'URI', |
| 63 | - 'type' => 'Text', |
|
| 64 | - 'width' => 'Length', |
|
| 65 | - 'height' => 'Length', |
|
| 66 | - 'poster' => 'URI', |
|
| 67 | - 'preload' => 'Enum#auto,metadata,none', |
|
| 68 | - 'controls' => 'Bool', |
|
| 63 | + 'type' => 'Text', |
|
| 64 | + 'width' => 'Length', |
|
| 65 | + 'height' => 'Length', |
|
| 66 | + 'poster' => 'URI', |
|
| 67 | + 'preload' => 'Enum#auto,metadata,none', |
|
| 68 | + 'controls' => 'Bool', |
|
| 69 | 69 | ]], |
| 70 | 70 | ['source', 'Block', 'Flow', 'Common', [ |
| 71 | - 'src' => 'URI', |
|
| 72 | - 'type' => 'Text', |
|
| 71 | + 'src' => 'URI', |
|
| 72 | + 'type' => 'Text', |
|
| 73 | 73 | ]], |
| 74 | 74 | |
| 75 | - // http://developers.whatwg.org/text-level-semantics.html |
|
| 75 | + // http://developers.whatwg.org/text-level-semantics.html |
|
| 76 | 76 | ['s', 'Inline', 'Inline', 'Common'], |
| 77 | 77 | ['var', 'Inline', 'Inline', 'Common'], |
| 78 | 78 | ['sub', 'Inline', 'Inline', 'Common'], |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ['mark', 'Inline', 'Inline', 'Common'], |
| 81 | 81 | ['wbr', 'Inline', 'Empty', 'Core'], |
| 82 | 82 | |
| 83 | - // http://developers.whatwg.org/edits.html |
|
| 83 | + // http://developers.whatwg.org/edits.html |
|
| 84 | 84 | ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], |
| 85 | 85 | ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], |
| 86 | 86 | ], |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!function_exists('clean')) { |
|
| 3 | +if ( ! function_exists('clean')) { |
|
| 4 | 4 | function clean($dirty, $config = null) |
| 5 | 5 | { |
| 6 | 6 | return app('purifier')->clean($dirty, $config); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function boot() |
| 23 | 23 | { |
| 24 | 24 | if ($this->app instanceof LaravelApplication) { |
| 25 | - $this->publishes([$this->getConfigSource() => config_path('purifier.php')]); |
|
| 25 | + $this->publishes([ $this->getConfigSource() => config_path('purifier.php') ]); |
|
| 26 | 26 | } elseif ($this->app instanceof LumenApplication) { |
| 27 | 27 | $this->app->configure('purifier'); |
| 28 | 28 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->mergeConfigFrom($this->getConfigSource(), 'purifier'); |
| 49 | 49 | |
| 50 | - $this->app->singleton('purifier', function (Container $app) { |
|
| 51 | - return new Purifier($app['files'], $app['config']); |
|
| 50 | + $this->app->singleton('purifier', function(Container $app) { |
|
| 51 | + return new Purifier($app[ 'files' ], $app[ 'config' ]); |
|
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | 54 | $this->app->alias('purifier', Purifier::class); |
@@ -61,6 +61,6 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function provides() |
| 63 | 63 | { |
| 64 | - return ['purifier']; |
|
| 64 | + return [ 'purifier' ]; |
|
| 65 | 65 | } |
| 66 | 66 | } |
@@ -143,11 +143,11 @@ |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | continue; |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - if (class_exists($validValues)) { |
|
| 149 | - $validValues = new $validValues(); |
|
| 150 | - } |
|
| 148 | + if (class_exists($validValues)) { |
|
| 149 | + $validValues = new $validValues(); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | $definition->addAttribute($onElement, $attrName, $validValues); |
| 153 | 153 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function setUp() |
| 63 | 63 | { |
| 64 | - if (!$this->config->has('purifier')) { |
|
| 64 | + if ( ! $this->config->has('purifier')) { |
|
| 65 | 65 | throw new Exception('Configuration parameters not loaded!'); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -85,30 +85,30 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | private function addCustomDefinition(array $definitionConfig, ?HTMLPurifier_Config $configObject = null) |
| 87 | 87 | { |
| 88 | - if (!$configObject) { |
|
| 88 | + if ( ! $configObject) { |
|
| 89 | 89 | $configObject = HTMLPurifier_Config::createDefault(); |
| 90 | 90 | $configObject->loadArray($this->getConfig()); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Setup the custom definition |
| 94 | - $configObject->set('HTML.DefinitionID', $definitionConfig['id']); |
|
| 95 | - $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']); |
|
| 94 | + $configObject->set('HTML.DefinitionID', $definitionConfig[ 'id' ]); |
|
| 95 | + $configObject->set('HTML.DefinitionRev', $definitionConfig[ 'rev' ]); |
|
| 96 | 96 | |
| 97 | 97 | // Enable debug mode |
| 98 | - if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) { |
|
| 98 | + if ( ! isset($definitionConfig[ 'debug' ]) || $definitionConfig[ 'debug' ]) { |
|
| 99 | 99 | $configObject->set('Cache.DefinitionImpl', null); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Start configuring the definition |
| 103 | 103 | if ($def = $configObject->maybeGetRawHTMLDefinition()) { |
| 104 | 104 | // Create the definition attributes |
| 105 | - if (!empty($definitionConfig['attributes'])) { |
|
| 106 | - $this->addCustomAttributes($definitionConfig['attributes'], $def); |
|
| 105 | + if ( ! empty($definitionConfig[ 'attributes' ])) { |
|
| 106 | + $this->addCustomAttributes($definitionConfig[ 'attributes' ], $def); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Create the definition elements |
| 110 | - if (!empty($definitionConfig['elements'])) { |
|
| 111 | - $this->addCustomElements($definitionConfig['elements'], $def); |
|
| 110 | + if ( ! empty($definitionConfig[ 'elements' ])) { |
|
| 111 | + $this->addCustomElements($definitionConfig[ 'elements' ], $def); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | foreach ($attributes as $attribute) { |
| 129 | 129 | // Get configuration of attribute |
| 130 | - $required = !empty($attribute[3]) ? true : false; |
|
| 131 | - $onElement = $attribute[0]; |
|
| 132 | - $attrName = $required ? $attribute[1] . '*' : $attribute[1]; |
|
| 133 | - $validValues = $attribute[2]; |
|
| 130 | + $required = ! empty($attribute[ 3 ]) ? true : false; |
|
| 131 | + $onElement = $attribute[ 0 ]; |
|
| 132 | + $attrName = $required ? $attribute[ 1 ].'*' : $attribute[ 1 ]; |
|
| 133 | + $validValues = $attribute[ 2 ]; |
|
| 134 | 134 | |
| 135 | 135 | if ($onElement === '*') { |
| 136 | 136 | $def = $validValues; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | if ($def instanceof \HTMLPurifier_AttrDef) { |
| 142 | - $definition->info_global_attr[$attrName] = $def; |
|
| 142 | + $definition->info_global_attr[ $attrName ] = $def; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | continue; |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | foreach ($elements as $element) { |
| 169 | 169 | // Get configuration of element |
| 170 | - $name = $element[0]; |
|
| 171 | - $contentSet = $element[1]; |
|
| 172 | - $allowedChildren = $element[2]; |
|
| 173 | - $attributeCollection = $element[3]; |
|
| 174 | - $attributes = isset($element[4]) ? $element[4] : null; |
|
| 170 | + $name = $element[ 0 ]; |
|
| 171 | + $contentSet = $element[ 1 ]; |
|
| 172 | + $allowedChildren = $element[ 2 ]; |
|
| 173 | + $attributeCollection = $element[ 3 ]; |
|
| 174 | + $attributes = isset($element[ 4 ]) ? $element[ 4 ] : null; |
|
| 175 | 175 | |
| 176 | - if (!empty($attributes)) { |
|
| 176 | + if ( ! empty($attributes)) { |
|
| 177 | 177 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes); |
| 178 | 178 | } else { |
| 179 | 179 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection); |
@@ -209,24 +209,24 @@ discard block |
||
| 209 | 209 | $configObject = HTMLPurifier_Config::createDefault(); |
| 210 | 210 | |
| 211 | 211 | // Allow configuration to be modified |
| 212 | - if (! $this->config->get('purifier.finalize')) { |
|
| 212 | + if ( ! $this->config->get('purifier.finalize')) { |
|
| 213 | 213 | $configObject->autoFinalize = false; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Set default config |
| 217 | - $defaultConfig = []; |
|
| 218 | - $defaultConfig['Core.Encoding'] = $this->config->get('purifier.encoding'); |
|
| 219 | - $defaultConfig['Cache.SerializerPath'] = $this->config->get('purifier.cachePath'); |
|
| 220 | - $defaultConfig['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 217 | + $defaultConfig = [ ]; |
|
| 218 | + $defaultConfig[ 'Core.Encoding' ] = $this->config->get('purifier.encoding'); |
|
| 219 | + $defaultConfig[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath'); |
|
| 220 | + $defaultConfig[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 221 | 221 | |
| 222 | - if (! $config) { |
|
| 222 | + if ( ! $config) { |
|
| 223 | 223 | $config = $this->config->get('purifier.settings.default'); |
| 224 | 224 | } elseif (is_string($config)) { |
| 225 | - $config = $this->config->get('purifier.settings.' . $config); |
|
| 225 | + $config = $this->config->get('purifier.settings.'.$config); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if (! is_array($config)) { |
|
| 229 | - $config = []; |
|
| 228 | + if ( ! is_array($config)) { |
|
| 229 | + $config = [ ]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Merge configurations |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | public function clean($dirty, $config = null, ?\Closure $postCreateConfigHook = null) |
| 267 | 267 | { |
| 268 | 268 | if (is_array($dirty)) { |
| 269 | - return array_map(function ($item) use ($config) { |
|
| 269 | + return array_map(function($item) use ($config) { |
|
| 270 | 270 | return $this->clean($item, $config); |
| 271 | 271 | }, $dirty); |
| 272 | 272 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | //If $dirty is not an explicit string, bypass purification assuming configuration allows this |
| 284 | 284 | $ignoreNonStrings = $this->config->get('purifier.ignoreNonStrings', false); |
| 285 | 285 | $stringTest = is_string($dirty); |
| 286 | - if($stringTest === false && $ignoreNonStrings === true) { |
|
| 286 | + if ($stringTest === false && $ignoreNonStrings === true) { |
|
| 287 | 287 | return $dirty; |
| 288 | 288 | } |
| 289 | 289 | |