]> source.dussan.org Git - nextcloud-server.git/commitdiff
Implement encodePath
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>
Thu, 4 Jul 2013 16:21:49 +0000 (19:21 +0300)
committerVictor Dubiniuk <victor.dubiniuk@gmail.com>
Tue, 9 Jul 2013 14:46:11 +0000 (17:46 +0300)
lib/public/util.php
lib/util.php

index 6744c2d37bdde2535f20a7646d8a307a2ccd1a17..d69602f4507af9654c60cc54b95aeaae544fd284 100644 (file)
@@ -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.
index 8f5f79b6b097a5c802f8c13f9bd836c9badba51c..981b05b2b46130a60318203705059da1c9e5fc88 100755 (executable)
@@ -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