From 5a3fce12a4496ec6d2903902e035af017e07f2f8 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Thu, 4 Jul 2013 19:21:49 +0300 Subject: [PATCH] Implement encodePath --- lib/public/util.php | 14 ++++++++++++++ lib/util.php | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/public/util.php b/lib/public/util.php index 6744c2d37bd..d69602f4507 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -355,6 +355,20 @@ class Util { public static function sanitizeHTML( $value ) { return(\OC_Util::sanitizeHTML($value)); } + + /** + * @brief Public function to encode url parameters + * + * This function is used to encode path to file before output. + * Encoding is done according to RFC 3986 with one exception: + * Character '/' is preserved as is. + * + * @param string $component part of URI to encode + * @return string + */ + public static function encodePath($component) { + return(\OC_Util::encodePath($component)); + } /** * @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. diff --git a/lib/util.php b/lib/util.php index 8f5f79b6b09..981b05b2b46 100755 --- a/lib/util.php +++ b/lib/util.php @@ -539,7 +539,22 @@ class OC_Util { } return $value; } - + + /** + * @brief Public function to encode url parameters + * + * This function is used to encode path to file before output. + * Encoding is done according to RFC 3986 with one exception: + * Character '/' is preserved as is. + * + * @param string $component part of URI to encode + * @return string + */ + public static function encodePath($component) { + $encoded = rawurlencode($component); + $encoded = str_replace('%2F', '/', $encoded); + return $encoded; + } /** * Check if the htaccess file is working by creating a test file in the data directory and trying to access via http -- 2.39.5