]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow 4byte unicode filenames on supported platforms
authorRobin Appelman <robin@icewind.nl>
Thu, 20 Oct 2016 12:26:09 +0000 (14:26 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 20 Oct 2016 12:26:09 +0000 (14:26 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/DB/Connection.php
lib/private/Files/View.php
lib/public/IDBConnection.php

index 4fa25aae08d3843917ec8a83fb5b328d248f4485..dfe2e86b61750b337065e9c533f771c90e74a2ae 100644 (file)
@@ -33,6 +33,7 @@ use Doctrine\DBAL\Driver;
 use Doctrine\DBAL\Configuration;
 use Doctrine\DBAL\Cache\QueryCacheProfile;
 use Doctrine\Common\EventManager;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
 use OC\DB\QueryBuilder\QueryBuilder;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
@@ -402,4 +403,14 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
        public function escapeLikeParameter($param) {
                return addcslashes($param, '\\_%');
        }
+
+       /**
+        * Check whether or not the current database support 4byte wide unicode
+        *
+        * @return bool
+        * @since 9.2.0
+        */
+       public function supports4ByteText() {
+               return ! ($this->getDatabasePlatform() instanceof MySqlPlatform && $this->getParams()['charset'] !== 'utf8mb4');
+       }
 }
index fa6ba20c342f37f33031d2b73a0057c5e46bad6f..56d7b716265bc3658f3b47132a149b016a8b55c8 100644 (file)
@@ -1806,13 +1806,15 @@ class View {
                        throw new InvalidPathException($l10n->t('Dot files are not allowed'));
                }
 
-               // verify database - e.g. mysql only 3-byte chars
-               if (preg_match('%(?:
+               if (!\OC::$server->getDatabaseConnection()->supports4ByteText()) {
+                       // verify database - e.g. mysql only 3-byte chars
+                       if (preg_match('%(?:
       \xF0[\x90-\xBF][\x80-\xBF]{2}      # planes 1-3
     | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
     | \xF4[\x80-\x8F][\x80-\xBF]{2}      # plane 16
 )%xs', $fileName)) {
-                       throw new InvalidPathException($l10n->t('4-byte characters are not supported in file names'));
+                               throw new InvalidPathException($l10n->t('4-byte characters are not supported in file names'));
+                       }
                }
 
                try {
index 188e715aba07641e64545dc99545a8cb9baea19d..317063422280c17f7162b71e4e5642f02a165aa7 100644 (file)
@@ -251,4 +251,12 @@ interface IDBConnection {
         * @since 9.0.0
         */
        public function escapeLikeParameter($param);
+
+       /**
+        * Check whether or not the current database support 4byte wide unicode
+        *
+        * @return bool
+        * @since 9.2.0
+        */
+       public function supports4ByteText();
 }