Skip to content

Commit 2a56b1f

Browse files
committed
null bytes
1 parent fbe23a3 commit 2a56b1f

12 files changed

Lines changed: 259 additions & 122 deletions

File tree

composer.lock

Lines changed: 164 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
>
10+
stopOnFailure="true">
1211
<testsuites>
1312
<testsuite name="unit">
1413
<directory>./tests/unit</directory>

src/Database/Adapter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,4 +1464,12 @@ public function enableAlterLocks(bool $enable): self
14641464

14651465
return $this;
14661466
}
1467+
1468+
/**
1469+
* Is schemas supported?
1470+
*
1471+
* @return bool
1472+
*/
1473+
abstract public function getSupportNonUtcCharacters(): bool;
1474+
14671475
}

src/Database/Adapter/MariaDB.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Utopia\Database\Database;
88
use Utopia\Database\Document;
99
use Utopia\Database\Exception as DatabaseException;
10+
use Utopia\Database\Exception\Character as CharacterException;
1011
use Utopia\Database\Exception\Duplicate as DuplicateException;
1112
use Utopia\Database\Exception\Limit as LimitException;
1213
use Utopia\Database\Exception\NotFound as NotFoundException;
@@ -1838,6 +1839,10 @@ public function getInternalIndexesKeys(): array
18381839

18391840
protected function processException(PDOException $e): \Exception
18401841
{
1842+
if ($e->getCode() === '22007' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 1366) {
1843+
return new CharacterException('Invalid character', $e->getCode(), $e);
1844+
}
1845+
18411846
// Timeout
18421847
if ($e->getCode() === '70100' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 1969) {
18431848
return new TimeoutException('Query timed out', $e->getCode(), $e);
@@ -2230,4 +2235,9 @@ public function getSupportForAlterLocks(): bool
22302235
{
22312236
return true;
22322237
}
2238+
2239+
public function getSupportNonUtcCharacters(): bool
2240+
{
2241+
return true;
2242+
}
22332243
}

src/Database/Adapter/Mongo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,4 +3221,9 @@ public function getSupportForAlterLocks(): bool
32213221
{
32223222
return false;
32233223
}
3224+
3225+
public function getSupportNonUtcCharacters(): bool
3226+
{
3227+
return false;
3228+
}
32243229
}

src/Database/Adapter/MySQL.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Utopia\Database\Exception\Dependency as DependencyException;
99
use Utopia\Database\Exception\Structure as StructureException;
1010
use Utopia\Database\Exception\Timeout as TimeoutException;
11+
use Utopia\Database\Exception\Character as CharacterException;
1112
use Utopia\Database\Operator;
1213
use Utopia\Database\Query;
1314

@@ -147,6 +148,10 @@ public function getSupportForCastIndexArray(): bool
147148

148149
protected function processException(PDOException $e): \Exception
149150
{
151+
if ($e->getCode() === 'HY000' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 1366) {
152+
return new CharacterException('Invalid character', $e->getCode(), $e);
153+
}
154+
150155
// Timeout
151156
if ($e->getCode() === 'HY000' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 3024) {
152157
return new TimeoutException('Query timed out', $e->getCode(), $e);

src/Database/Adapter/Pool.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,4 +642,9 @@ public function getSupportForAlterLocks(): bool
642642
{
643643
return $this->delegate(__FUNCTION__, \func_get_args());
644644
}
645+
646+
public function getSupportNonUtcCharacters(): bool
647+
{
648+
return $this->delegate(__FUNCTION__, \func_get_args());
649+
}
645650
}

src/Database/Adapter/Postgres.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,4 +2738,9 @@ protected function bindOperatorParams(\PDOStatement|PDOStatementProxy $stmt, Ope
27382738
break;
27392739
}
27402740
}
2741+
2742+
public function getSupportNonUtcCharacters(): bool
2743+
{
2744+
return false;
2745+
}
27412746
}

src/Database/Database.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9359,4 +9359,13 @@ private function rollbackAttributeMetadata(Document $collection, array $attribut
93599359
$collection->setAttribute('attributes', \array_values($filteredAttributes));
93609360
}
93619361

9362+
/**
9363+
* @param string $string
9364+
* @return string
9365+
*/
9366+
public function sanitizeNonUtf8(string $string): string
9367+
{
9368+
return $string;
9369+
}
9370+
93629371
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Utopia\Database\Exception;
4+
5+
use Utopia\Database\Exception;
6+
7+
class Character extends Exception
8+
{
9+
}

0 commit comments

Comments
 (0)