@@ -49,7 +49,7 @@ |
||
| 49 | 49 | /** |
| 50 | 50 | * Get the services provided by the provider. |
| 51 | 51 | * |
| 52 | - * @return array |
|
| 52 | + * @return string[] |
|
| 53 | 53 | */ |
| 54 | 54 | public function provides() |
| 55 | 55 | { |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $source = realpath(__DIR__.'/../config/purifier.php'); |
| 35 | 35 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
| 36 | - $this->publishes([$source => config_path('purifier.php')]); |
|
| 36 | + $this->publishes([ $source => config_path('purifier.php') ]); |
|
| 37 | 37 | } elseif ($this->app instanceof LumenApplication) { |
| 38 | 38 | $this->app->configure('purifier'); |
| 39 | 39 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function register() |
| 50 | 50 | { |
| 51 | - $this->app->singleton('purifier', function (Container $app) { |
|
| 52 | - return new Purifier($app['files'], $app['config']); |
|
| 51 | + $this->app->singleton('purifier', function(Container $app) { |
|
| 52 | + return new Purifier($app[ 'files' ], $app[ 'config' ]); |
|
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | $this->app->alias('purifier', Purifier::class); |
@@ -62,6 +62,6 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function provides() |
| 64 | 64 | { |
| 65 | - return ['purifier']; |
|
| 65 | + return [ 'purifier' ]; |
|
| 66 | 66 | } |
| 67 | 67 | } |
@@ -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); |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | /** |
| 182 | 182 | * @param null $config |
| 183 | 183 | * |
| 184 | - * @return mixed|null |
|
| 184 | + * @return HTMLPurifier_Config |
|
| 185 | 185 | */ |
| 186 | 186 | protected function getConfig($config = null) |
| 187 | 187 | { |
@@ -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 | $definition->addAttribute($onElement, $attrName, $validValues); |
| 136 | 136 | } |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | foreach ($elements as $element) { |
| 152 | 152 | // Get configuration of element |
| 153 | - $name = $element[0]; |
|
| 154 | - $contentSet = $element[1]; |
|
| 155 | - $allowedChildren = $element[2]; |
|
| 156 | - $attributeCollection = $element[3]; |
|
| 157 | - $attributes = isset($element[4]) ? $element[4] : null; |
|
| 153 | + $name = $element[ 0 ]; |
|
| 154 | + $contentSet = $element[ 1 ]; |
|
| 155 | + $allowedChildren = $element[ 2 ]; |
|
| 156 | + $attributeCollection = $element[ 3 ]; |
|
| 157 | + $attributes = isset($element[ 4 ]) ? $element[ 4 ] : null; |
|
| 158 | 158 | |
| 159 | - if (!empty($attributes)) { |
|
| 159 | + if ( ! empty($attributes)) { |
|
| 160 | 160 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes); |
| 161 | 161 | } else { |
| 162 | 162 | $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection); |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | $cachePath = $this->config->get('purifier.cachePath'); |
| 173 | 173 | |
| 174 | 174 | if ($cachePath) { |
| 175 | - if (!$this->files->isDirectory($cachePath)) { |
|
| 176 | - $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755),true); |
|
| 175 | + if ( ! $this->files->isDirectory($cachePath)) { |
|
| 176 | + $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755), true); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -189,24 +189,24 @@ discard block |
||
| 189 | 189 | $configObject = HTMLPurifier_Config::createDefault(); |
| 190 | 190 | |
| 191 | 191 | // Allow configuration to be modified |
| 192 | - if (! $this->config->get('purifier.finalize')) { |
|
| 192 | + if ( ! $this->config->get('purifier.finalize')) { |
|
| 193 | 193 | $configObject->autoFinalize = false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Set default config |
| 197 | - $defaultConfig = []; |
|
| 198 | - $defaultConfig['Core.Encoding'] = $this->config->get('purifier.encoding'); |
|
| 199 | - $defaultConfig['Cache.SerializerPath'] = $this->config->get('purifier.cachePath'); |
|
| 200 | - $defaultConfig['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 197 | + $defaultConfig = [ ]; |
|
| 198 | + $defaultConfig[ 'Core.Encoding' ] = $this->config->get('purifier.encoding'); |
|
| 199 | + $defaultConfig[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath'); |
|
| 200 | + $defaultConfig[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755); |
|
| 201 | 201 | |
| 202 | - if (! $config) { |
|
| 202 | + if ( ! $config) { |
|
| 203 | 203 | $config = $this->config->get('purifier.settings.default'); |
| 204 | 204 | } elseif (is_string($config)) { |
| 205 | - $config = $this->config->get('purifier.settings.' . $config); |
|
| 205 | + $config = $this->config->get('purifier.settings.'.$config); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if (! is_array($config)) { |
|
| 209 | - $config = []; |
|
| 208 | + if ( ! is_array($config)) { |
|
| 209 | + $config = [ ]; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // Merge configurations |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | public function clean($dirty, $config = null) |
| 247 | 247 | { |
| 248 | 248 | if (is_array($dirty)) { |
| 249 | - return array_map(function ($item) use ($config) { |
|
| 249 | + return array_map(function($item) use ($config) { |
|
| 250 | 250 | return $this->clean($item, $config); |
| 251 | 251 | }, $dirty); |
| 252 | 252 | } |