diff --git a/Security/EncryptionHelper.php b/Security/EncryptionHelper.php index 02120b3c9..0ba24b64c 100755 --- a/Security/EncryptionHelper.php +++ b/Security/EncryptionHelper.php @@ -193,7 +193,9 @@ final class EncryptionHelper continue; } - $ciphertext = \mb_substr($buffer, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); + // $ciphertext = \mb_substr($buffer, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); Not required due to previous nonce fread + + $ciphertext = $buffer; $plaintext = \sodium_crypto_secretbox_open($ciphertext, $nonce, $secretKey); if ($plaintext === false) { diff --git a/Security/PhpCode.php b/Security/PhpCode.php index a235249dd..b4bf4b027 100755 --- a/Security/PhpCode.php +++ b/Security/PhpCode.php @@ -92,8 +92,18 @@ final class PhpCode */ public static function hasUnicode(string $source) : bool { - return ((bool) \preg_match("/[\x01-\x7f]/", $source)) - || ((bool) \preg_match("/(0|\\\)x([a-fA-F0-9]){2}/", $source)); + $length = \mb_strlen($source, 'UTF-8'); + + for ($i = 0; $i < $length; ++$i) { + $char = \mb_substr($source, $i, 1, 'UTF-8'); + $codePoint = \ord($char); + + if ($codePoint > 127) { + return true; + } + } + + return false; } /** diff --git a/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php b/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php index fb70a76a5..215983907 100755 --- a/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php +++ b/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php @@ -104,8 +104,6 @@ class SpreadsheetDatabaseMapper implements IODatabaseMapper $cells[] = $workSheet->getCell(StringUtils::intToAlphabet($j) . $line)->getCalculatedValue(); } - \var_dump($cells); - ++$line; $query->values(...$cells); diff --git a/tests/Router/SocketRouterTest.php b/tests/Router/SocketRouterTest.php index 75216a9e4..72d7ebcdb 100755 --- a/tests/Router/SocketRouterTest.php +++ b/tests/Router/SocketRouterTest.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace phpOMS\tests\Router; use phpOMS\Account\Account; +use phpOMS\Account\NullAccount; use phpOMS\Account\PermissionAbstract; use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; @@ -134,7 +135,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase PermissionType::READ ) extends PermissionAbstract {}; - $account = new Account(); + $account = new NullAccount(1); $account->addPermission($perm); self::assertEquals(