@param string $input

@return string

@link http://www.apps.ietf.org/rfc/rfc3986.html#sec-5.2.4
978543
private function removeDotSegments(string $input): string {
        $output = '';

        $patternA = ',^(\.\.?/),';
        $patternB1 = ',^(/\./),';
        $patternB2 = ',^(/\.)$,';
        $patternC = ',^(/\.\./|/\.\.),';
        // $patternD  = ',^(\.\.?)$,';
        $patternE = ',(/*[^/]*),';

        while ($input !== '') {
            if (\preg_match($patternA, $input)) {
                $input = \preg_replace($patternA, '', $input);
            } elseif (\preg_match($patternB1, $input, $match) || \preg_match($patternB2, $input, $match)) {
                $input = preg_replace(",^" . $match[1] . ",", '/', $input);
            } elseif (\preg_match($patternC, $input, $match)) {
                $input = \preg_replace(',^' . \preg_quote($match[1], ',') . ',', '/', $input);
                $output = \preg_replace(',/([^/]+)$,', '', $output);
            } elseif ($input === '.' || $input === '..') { // pattern D
                $input = '';
            } elseif (\preg_match($patternE, $input, $match)) {
                $initialSegment = $match[1];
                $input = \preg_replace(',^' . \preg_quote($initialSegment, ',') . ',', '', $input, 1);
                $output .= $initialSegment;
            }
        }

        return $output;
    }
1332027
public function formatString($input)
    {
        if (is_array($input)) {
            $input = join(', ', $input);
        }
        $output = strip_tags($input);
        $output = str_replace(array("\r", "\n"), array(' ', ' '), $output);
        
        $output = $this->filterCsvInjection($output);
        
        return $output;
    }
920119
public function encode($input)
    {
        $parts = explode('.', $input);

        foreach ($parts as &$part) {
            $part = $this->_encodePart($part);
        }

        return implode('.', $parts);
    }
1016464
public static function camelCase(string $input)
    {
        $words = __::words(preg_replace("/['\x{2019}]/u", '', $input));

        return array_reduce(
            $words,
            function ($result, $word) use ($words) {
                $isFirst = __::first($words) === $word;
                $word = __::toLower($word);

                return $result . (!$isFirst ? __::capitalize($word) : $word);
            },
            ''
        );
    }
94543
protected function _fromBase64url($input)
    {
        $remainder = strlen($input) % 4;
        if ($remainder)
        {
            $padlen = 4 - $remainder;
            $input .= str_repeat('=', $padlen);
        }

        return base64_decode(strtr($input, '-_', '+/'));
    }
226674
protected function decryptMcrypt($input)
    {
        $ivlen = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
        $iv    = substr($input, 0, $ivlen);
        $key   = md5($this->offsetExists('salt') ? $this->offsetGet('salt') : 'vadf2646fakjndkjn24656452vqk');

        // Remove trailing zero bytes!
        return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, substr($input, $ivlen), MCRYPT_MODE_CBC, $iv), "\0");
    }
398690
public static function getMacrosMatch($input)
    {
        $before = array(":num",
            ":char",
            ":charNum",
            ":text",
            ":img",
            "/",
        );
        $after = array(
            "[0-9]*",
            "[A-Za-z]*",
            "[A-Za-z0-9-]*",
            "[A-Za-z0-9- .,:%+;]*",
            ".*[.](png|jpg|jpeg|gif)",
            '\/',
        );
        $routePreg = str_replace($before, $after, $input);
        $routePreg = "/^" . $routePreg . "$/i";
        return $routePreg;
    }
37880
private function getOutput($input)
	{
		$return = Api::decrypt($this->createkey() , $input);
		if (!is_array($return)) {
			ob_start();
			$return = json_decode(trim(base64_decode($input)), true);
			ob_end_clean();
		}
		if (!is_array($return)) {
			$this->error[] = 'JfusionAPI: error output: ' . $input;
			return false;
		} else if (isset($return['PHPSESSID'])) {
			$this->sid = $return['PHPSESSID'];
		}

		if (isset($return['debug'])) {
			$this->debug = $return['debug'];
		}
		if (isset($return['error']) && !empty($return['error'])) {
			return false;
		} else if (isset($return['payload'])) {
			return $return['payload'];
		}
		return true;
	}
1215511
public function validate( $input )
    {
        // Check if we received a unix timestamp, in this case we can just
        // directly convert and return it.
        if ( is_numeric( $input ) )
        {
            $date = new DateTime( '@' . $input );
            return $date->format( DATE_RFC2822 );
        }

        // Otherwise we received most presumably some phpillowrary string, which
        // we first just try to parse with datetime (strtotime).
        if ( ( $date = new DateTime( $input ) ) !== false )
        {
            return $date->format( DATE_RFC2822 );
        }

        // If DateTime could not parse the string, we got a problem. Maybe
        // handle more datetime formats here manually, but now we just fail.
        //
        // Since PHP 5.3 datetime seems to accept everything and just returns
        // NOW, if it fails to parse. So this seems untestable for now.
        throw new phpillowValidationException( 
            'Error parsing the date: %date', 
            array(
                'date' => $input,
            )
        );
    }
1282386
protected function validator($input)
    {
        $this->checkValue($input);

        if ($this->hasErrors()) {
            return '';
        }

        if (!$input) {
            if ($this->mandatory) {
                $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
            }

            return '';
        } elseif (false === strpos($input, ',')) {
            return $this->multiple ? [(int) $input] : (int) $input;
        }
        $arrValue = array_map('intval', array_filter(explode(',', $input)));

        return $this->multiple ? $arrValue : $arrValue[0];
    }
1289163
public function encode($input)
    {
        $input = mb_strtolower($input, $this->encoding);
        $parts = explode('.', $input);
        foreach ($parts as &$part) {
            $length = strlen($part);
            if ($length < 1) {
                throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
            }
            $part = $this->encodePart($part);
        }
        $output = implode('.', $parts);
        $length = strlen($output);
        if ($length > 255) {
            throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
        }

        return $output;
    }
1193082
public function makenice($input)
    {
        $output = strip_tags($input);
        $output = $this->autolink($output);
        $output = nl2br($output);

        return $output;
    }
599813
public function decode($input)
    {
        $this->value = trim(
            mcrypt_decrypt(
                MCRYPT_RIJNDAEL_256,
                $this->secureKey,
                base64_decode($input),
                MCRYPT_MODE_ECB,
                $this->iv
            )
        );

        return $this->value;
    }
97107
public static function toKey($input)
    {
        // Remove spaces and dashes, then convert to lower case.
        $input = self::toUnderscoreSeparated($input);
        $input = strtolower($input);

        return $input;
    }
1171445
public function translateFromUtf8($input)
    {
        if ($this->isRunningOnWindows()) {
            $input = iconv('UTF-8', mb_detect_encoding($input), $input);
        }

        return $input;
    }
260430
protected static function Base64UrlEncode( $input ) {
			/**
			 * IMPORTANT NOTE:
			 * This is a hack suggested by @otto42 and @greenshady from
			 * the theme's review team. The usage of base64 for API
			 * signature encoding was approved in a Slack meeting
			 * held on Tue (10/25 2016).
			 *
			 * @todo Remove this hack once the base64 error is removed from the Theme Check.
			 *
			 * @since 1.2.2
			 * @author Vova Feldman (@svovaf)
			 */
			$fn = 'base64' . '_encode';
			$str = strtr( $fn( $input ), '+/', '-_' );
			$str = str_replace( '=', '', $str );

			return $str;
		}
845932
public static function safe_base64_decode($input) {
    $remainder = strlen($input) % 4;
    if ($remainder) {
      $padlen = 4 - $remainder;
      $input .= str_repeat('=', $padlen);
    }
    return base64_decode(strtr($input, '-_', '+/'));
  }