@@ -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 | |
@@ -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 | } |
@@ -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; |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | foreach ($elements as $element) { |
| 165 | 165 | // Get configuration of element |
| 166 | - $name = $element[0]; |
|
| 167 | - $contentSet = $element[1]; |
|
| 168 | - $allowedChildren = $element[2]; |
|
| 169 | - $attributeCollection = $element[3]; |
|
| 170 | - $attributes = isset($element[4]) ? $element[4] : null; |
|
| 166 | + $name = $element[ 0 ]; |
|
| 167 | + $contentSet = $element[ 1 ]; |
|
| 168 | + $allowedChildren = $element[ 2 ]; |
|
| 169 | + $attributeCollection = $element[ 3 ]; |
|
| 170 | + $attributes = isset($element[ 4 ]) ? $element[ 4 ] : null; |
|
| 171 | 171 | |
| 172 | - if (!empty($attributes)) { |
|
| 172 | + if ( ! empty($attributes)) { |
|
| 173 | 173 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes); |
| 174 | 174 | } else { |
| 175 | 175 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection); |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | $cachePath = $this->config->get('purifier.cachePath'); |
| 186 | 186 | |
| 187 | 187 | if ($cachePath) { |
| 188 | - if (!$this->files->isDirectory($cachePath)) { |
|
| 189 | - $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755),true); |
|
| 188 | + if ( ! $this->files->isDirectory($cachePath)) { |
|
| 189 | + $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755), true); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | $configObject = HTMLPurifier_Config::createDefault(); |
| 203 | 203 | |
| 204 | 204 | // Allow configuration to be modified |
| 205 | - if (! $this->config->get('purifier.finalize')) { |
|
| 205 | + if ( ! $this->config->get('purifier.finalize')) { |
|
| 206 | 206 | $configObject->autoFinalize = false; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Set default config |
| 210 | - $defaultConfig = []; |
|
| 211 | - $defaultConfig['Core.Encoding'] = $this->config->get('purifier.encoding'); |
|
| 212 | - $defaultConfig['Cache.SerializerPath'] = $this->config->get('purifier.cachePath'); |
|
| 213 | - $defaultConfig['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 210 | + $defaultConfig = [ ]; |
|
| 211 | + $defaultConfig[ 'Core.Encoding' ] = $this->config->get('purifier.encoding'); |
|
| 212 | + $defaultConfig[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath'); |
|
| 213 | + $defaultConfig[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 214 | 214 | |
| 215 | - if (! $config) { |
|
| 215 | + if ( ! $config) { |
|
| 216 | 216 | $config = $this->config->get('purifier.settings.default'); |
| 217 | 217 | } elseif (is_string($config)) { |
| 218 | - $config = $this->config->get('purifier.settings.' . $config); |
|
| 218 | + $config = $this->config->get('purifier.settings.'.$config); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if (! is_array($config)) { |
|
| 222 | - $config = []; |
|
| 221 | + if ( ! is_array($config)) { |
|
| 222 | + $config = [ ]; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Merge configurations |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | public function clean($dirty, $config = null, \Closure $postCreateConfigHook = null) |
| 260 | 260 | { |
| 261 | 261 | if (is_array($dirty)) { |
| 262 | - return array_map(function ($item) use ($config) { |
|
| 262 | + return array_map(function($item) use ($config) { |
|
| 263 | 263 | return $this->clean($item, $config); |
| 264 | 264 | }, $dirty); |
| 265 | 265 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | //If $dirty is not an explicit string, bypass purification assuming configuration allows this |
| 277 | 277 | $ignoreNonStrings = $this->config->get('purifier.ignoreNonStrings', false); |
| 278 | 278 | $stringTest = is_string($dirty); |
| 279 | - if($stringTest === false && $ignoreNonStrings === true) { |
|
| 279 | + if ($stringTest === false && $ignoreNonStrings === true) { |
|
| 280 | 280 | return $dirty; |
| 281 | 281 | } |
| 282 | 282 | |