Exemplo n.º 1
1
 /**
  * Removes broken HTML and XSS from text using [HTMLPurifier](http://htmlpurifier.org/).
  *
  *     $text = Purifier::clean($dirty_html);
  *
  * The original content is returned with all broken HTML and XSS removed.
  *
  * @param   mixed   text to clean, or an array to clean recursively
  * @param   mixed   optional set of configuration options, as an array or a string denoting a set of options in the config file
  * @return  mixed
  */
 public static function clean($dirty, $config = null)
 {
     if (is_array($dirty)) {
         foreach ($dirty as $key => $value) {
             // Recursively clean arrays
             $clean[$key] = Purifier::clean($value, $config);
         }
     } else {
         // Load HTML Purifier
         $purifier = Purifier::instance();
         // Clean the HTML and return it
         if (is_array($config)) {
             $c = HTMLPurifier_Config::inherit(Purifier::$configs['default']);
             $c->loadArray($config);
             $clean = $purifier->purify($dirty, $c);
         } else {
             if (is_string($config)) {
                 if (isset(Purifier::$configs[$config])) {
                     $c = Purifier::$configs[$config];
                 } else {
                     $c = HTMLPurifier_Config::inherit(Purifier::$configs['default']);
                     $c->loadArray(Config::get('purifier::config.settings.' . $config));
                     Purifier::$configs[$config] = $c;
                 }
                 $clean = $purifier->purify($dirty, $c);
             } else {
                 $clean = $purifier->purify($dirty, Purifier::$configs['default']);
             }
         }
     }
     return $clean;
 }
 public function clean($value)
 {
     return $this->purifier->clean($value);
 }
 /**
  * Get HTMLPurifier instance.
  *
  * @return \HTMLPurifier 
  * @static 
  */
 public static function getInstance()
 {
     return \Mews\Purifier\Purifier::getInstance();
 }
Exemplo n.º 4
0
 /**
  * Removes broken HTML and XSS from text using [HTMLPurifier](http://htmlpurifier.org/).
  * 
  * $text = Purifier::clean($dirty_html);
  * 
  * The original content is returned with all broken HTML and XSS removed.
  *
  * @param mixed  text to clean, or an array to clean recursively
  * @param mixed  optional set of configuration options, as an array or a string denoting a set of options in the config file
  * @return mixed 
  * @static 
  */
 public static function clean($dirty, $config = null)
 {
     return \Mews\Purifier\Purifier::clean($dirty, $config);
 }
Exemplo n.º 5
0
 /**
  * Return the user input.
  *
  * @return array
  */
 private function getUserInput()
 {
     $input = $this->getApiServer()->getRequest()->all();
     $purifier_config = Config::get('purifier.config');
     if (is_array($input)) {
         if (count($input) > 0) {
             foreach ($input as $key => $value) {
                 if (strpos($key, '/') !== false) {
                     unset($input[$key]);
                 } else {
                     if (is_array($value)) {
                         if (!empty($value)) {
                             $input[$key] = Purifier::clean($value);
                         }
                     } else {
                         $input[$key] = Purifier::clean($value);
                     }
                 }
             }
         }
     }
     $input['username'] = isset($input['username']) ? $input['username'] : '';
     return $input;
 }