예제 #1
0
 protected function sanitizeValue($value, $mode)
 {
     if (!isset($value)) {
         return null;
     }
     if ($mode === self::SANITIZE_DISABLE) {
         return $value;
     }
     if ($mode & self::SANITIZE_TO_TYPE) {
         $value = Helper::toType($value);
     }
     if (!is_string($value)) {
         return $value;
     }
     if ($mode & self::SANITIZE_STRIP_TAGS) {
         $value = strip_tags($value);
     }
     if ($mode & self::SANITIZE_ESCAPE) {
         $value = StringHelper::encode($value);
     }
     return $value;
 }
예제 #2
0
 /**
  * Encodes special characters into HTML entities.
  *
  * @param string $value
  * @return string
  */
 public static function encode($value)
 {
     return StringHelper::encode($value);
 }
예제 #3
0
 /**
  * @inheritdoc
  */
 public function sanitize($input)
 {
     return is_string($input) ? \rock\helpers\StringHelper::encode($input, $this->doubleEncode) : $input;
 }
예제 #4
0
 /**
  * Encodes special characters into HTML entities.
  *
  * The {@see \rock\Rock::$charset} will be used for encoding.
  *
  * @param string $content the content to be encoded
  * @param boolean $doubleEncode whether to encode HTML entities in `$content`. If false,
  *                              HTML entities in `$content` will not be further encoded.
  * @return string the encoded content
  * @see decode()
  * @see http://www.php.net/manual/en/function.htmlspecialchars.php
  */
 public static function encode($content, $doubleEncode = true)
 {
     return StringHelper::encode($content, $doubleEncode);
 }