29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-24 22:39:31 +00:00

Update PHP dependencies through composer (#20802)

This commit is contained in:
Allon Moritz 2018-06-20 12:54:18 +02:00 committed by George Wilson
parent 69784826f3
commit 79f0d5dd67
124 changed files with 2333 additions and 905 deletions

497
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,13 @@ return array(
'Joomla\\Application\\AbstractApplication' => $vendorDir . '/joomla/application/src/AbstractApplication.php',
'Joomla\\Application\\AbstractWebApplication' => $vendorDir . '/joomla/application/src/AbstractWebApplication.php',
'Joomla\\Application\\ApplicationEvents' => $vendorDir . '/joomla/application/src/ApplicationEvents.php',
'Joomla\\Application\\Controller\\ContainerControllerResolver' => $vendorDir . '/joomla/application/src/Controller/ContainerControllerResolver.php',
'Joomla\\Application\\Controller\\ControllerResolver' => $vendorDir . '/joomla/application/src/Controller/ControllerResolver.php',
'Joomla\\Application\\Controller\\ControllerResolverInterface' => $vendorDir . '/joomla/application/src/Controller/ControllerResolverInterface.php',
'Joomla\\Application\\Event\\ApplicationErrorEvent' => $vendorDir . '/joomla/application/src/Event/ApplicationErrorEvent.php',
'Joomla\\Application\\Event\\ApplicationEvent' => $vendorDir . '/joomla/application/src/Event/ApplicationEvent.php',
'Joomla\\Application\\Exception\\UnableToWriteBody' => $vendorDir . '/joomla/application/src/Exception/UnableToWriteBody.php',
'Joomla\\Application\\WebApplication' => $vendorDir . '/joomla/application/src/WebApplication.php',
'Joomla\\Application\\Web\\WebClient' => $vendorDir . '/joomla/application/src/Web/WebClient.php',
'Joomla\\Archive\\Archive' => $vendorDir . '/joomla/archive/src/Archive.php',
'Joomla\\Archive\\Bzip2' => $vendorDir . '/joomla/archive/src/Bzip2.php',
@ -665,7 +670,6 @@ return array(
'Joomla\\Event\\ListenersPriorityQueue' => $vendorDir . '/joomla/event/src/ListenersPriorityQueue.php',
'Joomla\\Event\\Priority' => $vendorDir . '/joomla/event/src/Priority.php',
'Joomla\\Event\\SubscriberInterface' => $vendorDir . '/joomla/event/src/SubscriberInterface.php',
'Joomla\\Event\\SubscriberManagerInterface' => $vendorDir . '/joomla/event/src/SubscriberManagerInterface.php',
'Joomla\\Filesystem\\Buffer' => $vendorDir . '/joomla/filesystem/src/Buffer.php',
'Joomla\\Filesystem\\Clients\\FtpClient' => $vendorDir . '/joomla/filesystem/src/Clients/FtpClient.php',
'Joomla\\Filesystem\\Exception\\FilesystemException' => $vendorDir . '/joomla/filesystem/src/Exception/FilesystemException.php',
@ -934,13 +938,13 @@ return array(
'Symfony\\Component\\Yaml\\Tag\\TaggedValue' => $vendorDir . '/symfony/yaml/Tag/TaggedValue.php',
'Symfony\\Component\\Yaml\\Unescaper' => $vendorDir . '/symfony/yaml/Unescaper.php',
'Symfony\\Component\\Yaml\\Yaml' => $vendorDir . '/symfony/yaml/Yaml.php',
'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
'Symfony\\Polyfill\\Mbstring\\Mbstring' => $vendorDir . '/symfony/polyfill-mbstring/Mbstring.php',
'Symfony\\Polyfill\\Php56\\Php56' => $vendorDir . '/symfony/polyfill-php56/Php56.php',
'Symfony\\Polyfill\\Util\\Binary' => $vendorDir . '/symfony/polyfill-util/Binary.php',
'Symfony\\Polyfill\\Util\\BinaryNoFuncOverload' => $vendorDir . '/symfony/polyfill-util/BinaryNoFuncOverload.php',
'Symfony\\Polyfill\\Util\\BinaryOnFuncOverload' => $vendorDir . '/symfony/polyfill-util/BinaryOnFuncOverload.php',
'Symfony\\Polyfill\\Util\\LegacyTestListener' => $vendorDir . '/symfony/polyfill-util/LegacyTestListener.php',
'Symfony\\Polyfill\\Util\\TestListener' => $vendorDir . '/symfony/polyfill-util/TestListener.php',
'Symfony\\Polyfill\\Util\\TestListenerTrait' => $vendorDir . '/symfony/polyfill-util/TestListenerTrait.php',
'Zend\\Diactoros\\AbstractSerializer' => $vendorDir . '/zendframework/zend-diactoros/src/AbstractSerializer.php',
'Zend\\Diactoros\\CallbackStream' => $vendorDir . '/zendframework/zend-diactoros/src/CallbackStream.php',

View File

@ -22,6 +22,7 @@ return array(
'4292e2fa66516089e6006723267587b4' => $vendorDir . '/joomla/string/src/phputf8/utils/ascii.php',
'87465e33b7551b401bf051928f220e9a' => $vendorDir . '/joomla/string/src/phputf8/utils/validation.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',

View File

@ -10,6 +10,7 @@ return array(
'Symfony\\Polyfill\\Util\\' => array($vendorDir . '/symfony/polyfill-util'),
'Symfony\\Polyfill\\Php56\\' => array($vendorDir . '/symfony/polyfill-php56'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Symfony\\Component\\WebLink\\' => array($vendorDir . '/symfony/web-link'),
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),

View File

@ -23,6 +23,7 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
'4292e2fa66516089e6006723267587b4' => __DIR__ . '/..' . '/joomla/string/src/phputf8/utils/ascii.php',
'87465e33b7551b401bf051928f220e9a' => __DIR__ . '/..' . '/joomla/string/src/phputf8/utils/validation.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
'3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
@ -38,6 +39,7 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
'Symfony\\Polyfill\\Util\\' => 22,
'Symfony\\Polyfill\\Php56\\' => 23,
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Polyfill\\Ctype\\' => 23,
'Symfony\\Component\\Yaml\\' => 23,
'Symfony\\Component\\WebLink\\' => 26,
'Symfony\\Component\\OptionsResolver\\' => 34,
@ -120,6 +122,10 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Polyfill\\Ctype\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
),
'Symfony\\Component\\Yaml\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/yaml',
@ -313,8 +319,13 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
'Joomla\\Application\\AbstractApplication' => __DIR__ . '/..' . '/joomla/application/src/AbstractApplication.php',
'Joomla\\Application\\AbstractWebApplication' => __DIR__ . '/..' . '/joomla/application/src/AbstractWebApplication.php',
'Joomla\\Application\\ApplicationEvents' => __DIR__ . '/..' . '/joomla/application/src/ApplicationEvents.php',
'Joomla\\Application\\Controller\\ContainerControllerResolver' => __DIR__ . '/..' . '/joomla/application/src/Controller/ContainerControllerResolver.php',
'Joomla\\Application\\Controller\\ControllerResolver' => __DIR__ . '/..' . '/joomla/application/src/Controller/ControllerResolver.php',
'Joomla\\Application\\Controller\\ControllerResolverInterface' => __DIR__ . '/..' . '/joomla/application/src/Controller/ControllerResolverInterface.php',
'Joomla\\Application\\Event\\ApplicationErrorEvent' => __DIR__ . '/..' . '/joomla/application/src/Event/ApplicationErrorEvent.php',
'Joomla\\Application\\Event\\ApplicationEvent' => __DIR__ . '/..' . '/joomla/application/src/Event/ApplicationEvent.php',
'Joomla\\Application\\Exception\\UnableToWriteBody' => __DIR__ . '/..' . '/joomla/application/src/Exception/UnableToWriteBody.php',
'Joomla\\Application\\WebApplication' => __DIR__ . '/..' . '/joomla/application/src/WebApplication.php',
'Joomla\\Application\\Web\\WebClient' => __DIR__ . '/..' . '/joomla/application/src/Web/WebClient.php',
'Joomla\\Archive\\Archive' => __DIR__ . '/..' . '/joomla/archive/src/Archive.php',
'Joomla\\Archive\\Bzip2' => __DIR__ . '/..' . '/joomla/archive/src/Bzip2.php',
@ -946,7 +957,6 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
'Joomla\\Event\\ListenersPriorityQueue' => __DIR__ . '/..' . '/joomla/event/src/ListenersPriorityQueue.php',
'Joomla\\Event\\Priority' => __DIR__ . '/..' . '/joomla/event/src/Priority.php',
'Joomla\\Event\\SubscriberInterface' => __DIR__ . '/..' . '/joomla/event/src/SubscriberInterface.php',
'Joomla\\Event\\SubscriberManagerInterface' => __DIR__ . '/..' . '/joomla/event/src/SubscriberManagerInterface.php',
'Joomla\\Filesystem\\Buffer' => __DIR__ . '/..' . '/joomla/filesystem/src/Buffer.php',
'Joomla\\Filesystem\\Clients\\FtpClient' => __DIR__ . '/..' . '/joomla/filesystem/src/Clients/FtpClient.php',
'Joomla\\Filesystem\\Exception\\FilesystemException' => __DIR__ . '/..' . '/joomla/filesystem/src/Exception/FilesystemException.php',
@ -1215,13 +1225,13 @@ class ComposerStaticInita4c4383b02fcf9dfb95cc0397c641cf1
'Symfony\\Component\\Yaml\\Tag\\TaggedValue' => __DIR__ . '/..' . '/symfony/yaml/Tag/TaggedValue.php',
'Symfony\\Component\\Yaml\\Unescaper' => __DIR__ . '/..' . '/symfony/yaml/Unescaper.php',
'Symfony\\Component\\Yaml\\Yaml' => __DIR__ . '/..' . '/symfony/yaml/Yaml.php',
'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
'Symfony\\Polyfill\\Mbstring\\Mbstring' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/Mbstring.php',
'Symfony\\Polyfill\\Php56\\Php56' => __DIR__ . '/..' . '/symfony/polyfill-php56/Php56.php',
'Symfony\\Polyfill\\Util\\Binary' => __DIR__ . '/..' . '/symfony/polyfill-util/Binary.php',
'Symfony\\Polyfill\\Util\\BinaryNoFuncOverload' => __DIR__ . '/..' . '/symfony/polyfill-util/BinaryNoFuncOverload.php',
'Symfony\\Polyfill\\Util\\BinaryOnFuncOverload' => __DIR__ . '/..' . '/symfony/polyfill-util/BinaryOnFuncOverload.php',
'Symfony\\Polyfill\\Util\\LegacyTestListener' => __DIR__ . '/..' . '/symfony/polyfill-util/LegacyTestListener.php',
'Symfony\\Polyfill\\Util\\TestListener' => __DIR__ . '/..' . '/symfony/polyfill-util/TestListener.php',
'Symfony\\Polyfill\\Util\\TestListenerTrait' => __DIR__ . '/..' . '/symfony/polyfill-util/TestListenerTrait.php',
'Zend\\Diactoros\\AbstractSerializer' => __DIR__ . '/..' . '/zendframework/zend-diactoros/src/AbstractSerializer.php',
'Zend\\Diactoros\\CallbackStream' => __DIR__ . '/..' . '/zendframework/zend-diactoros/src/CallbackStream.php',

View File

@ -59,17 +59,17 @@
},
{
"name": "defuse/php-encryption",
"version": "v2.1.0",
"version_normalized": "2.1.0.0",
"version": "v2.2.0",
"version_normalized": "2.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/defuse/php-encryption.git",
"reference": "5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689"
"reference": "0d4d27c368ca6798bc162469e43248c363c73495"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/defuse/php-encryption/zipball/5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689",
"reference": "5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689",
"url": "https://api.github.com/repos/defuse/php-encryption/zipball/0d4d27c368ca6798bc162469e43248c363c73495",
"reference": "0d4d27c368ca6798bc162469e43248c363c73495",
"shasum": ""
},
"require": {
@ -78,10 +78,10 @@
"php": ">=5.4.0"
},
"require-dev": {
"nikic/php-parser": "^2.0|^3.0",
"nikic/php-parser": "^2.0|^3.0|^4.0",
"phpunit/phpunit": "^4|^5"
},
"time": "2017-05-18T21:28:48+00:00",
"time": "2018-04-23T19:33:40+00:00",
"bin": [
"bin/generate-defuse-key"
],
@ -301,12 +301,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/application.git",
"reference": "9fc3da51bedebaece1d32cb5a1923633b1932953"
"reference": "ca4c5a10a0efe7c2d9d413a05572ee26b1f7b6f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/application/zipball/9fc3da51bedebaece1d32cb5a1923633b1932953",
"reference": "9fc3da51bedebaece1d32cb5a1923633b1932953",
"url": "https://api.github.com/repos/joomla-framework/application/zipball/ca4c5a10a0efe7c2d9d413a05572ee26b1f7b6f4",
"reference": "ca4c5a10a0efe7c2d9d413a05572ee26b1f7b6f4",
"shasum": ""
},
"require": {
@ -320,17 +320,22 @@
},
"require-dev": {
"joomla/coding-standards": "~2.0@alpha",
"joomla/event": "~2.0",
"joomla/controller": "~1.0|~2.0",
"joomla/di": "~1.5|~2.0",
"joomla/router": "~2.0",
"joomla/session": "~2.0",
"joomla/test": "~1.1",
"joomla/uri": "~1.1",
"phpunit/phpunit": "~6.3"
},
"suggest": {
"joomla/controller": "To support resolving ControllerInterface objects in ControllerResolverInterface, install joomla/controller",
"joomla/router": "To use WebApplication or ControllerResolverInterface implementations, install joomla/router",
"joomla/session": "To use AbstractWebApplication with session support, install joomla/session",
"joomla/uri": "To use AbstractWebApplication, install joomla/uri"
"joomla/uri": "To use AbstractWebApplication, install joomla/uri",
"psr/container": "To use the ContainerControllerResolver, install any PSR-11 compatible container"
},
"time": "2018-03-15T01:47:40+00:00",
"time": "2018-05-28T15:33:35+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -416,12 +421,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/authentication.git",
"reference": "aaaa50a0ffdb8e47e719b1c74f8308ac95dfc957"
"reference": "62014f2516f77cf6e2c6b3d772bb5dae53d6fc3d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/authentication/zipball/aaaa50a0ffdb8e47e719b1c74f8308ac95dfc957",
"reference": "aaaa50a0ffdb8e47e719b1c74f8308ac95dfc957",
"url": "https://api.github.com/repos/joomla-framework/authentication/zipball/62014f2516f77cf6e2c6b3d772bb5dae53d6fc3d",
"reference": "62014f2516f77cf6e2c6b3d772bb5dae53d6fc3d",
"shasum": ""
},
"require": {
@ -439,7 +444,7 @@
"joomla/database": "Required if you want to use Joomla\\Authentication\\Strategies\\DatabaseStrategy",
"joomla/input": "Required if you want to use classes in the Joomla\\Authentication\\Strategies namespace"
},
"time": "2018-01-30T01:56:04+00:00",
"time": "2018-05-13T23:00:40+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -471,12 +476,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/console.git",
"reference": "b625aebe2dcc572facded26e552130517919b8de"
"reference": "2843800b0df2c4519c18d6eb9d56f9c7b1daa6ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/console/zipball/b625aebe2dcc572facded26e552130517919b8de",
"reference": "b625aebe2dcc572facded26e552130517919b8de",
"url": "https://api.github.com/repos/joomla-framework/console/zipball/2843800b0df2c4519c18d6eb9d56f9c7b1daa6ad",
"reference": "2843800b0df2c4519c18d6eb9d56f9c7b1daa6ad",
"shasum": ""
},
"require": {
@ -494,7 +499,7 @@
"suggest": {
"psr/container": "To use the ContainerLoader"
},
"time": "2018-03-18T01:08:13+00:00",
"time": "2018-05-21T17:08:36+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -683,12 +688,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/database.git",
"reference": "be0ec4fd70d727b17ba9017c2ae03fc344a9f02c"
"reference": "ccf0eaacb81792742f6def319e780eed917e5faf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/database/zipball/be0ec4fd70d727b17ba9017c2ae03fc344a9f02c",
"reference": "be0ec4fd70d727b17ba9017c2ae03fc344a9f02c",
"url": "https://api.github.com/repos/joomla-framework/database/zipball/ccf0eaacb81792742f6def319e780eed917e5faf",
"reference": "ccf0eaacb81792742f6def319e780eed917e5faf",
"shasum": ""
},
"require": {
@ -712,7 +717,7 @@
"joomla/di": "To use the Database ServiceProviderInterface objects, install joomla/di.",
"joomla/registry": "To use the Database ServiceProviderInterface objects, install joomla/registry."
},
"time": "2018-06-02T02:43:07+00:00",
"time": "2018-06-13T21:09:31+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -798,12 +803,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/event.git",
"reference": "71d0e41338a9e6cf8682f171fb483c7efb591876"
"reference": "9092ee2dc3fd010c7759c4467a93397c1dac8026"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/event/zipball/71d0e41338a9e6cf8682f171fb483c7efb591876",
"reference": "71d0e41338a9e6cf8682f171fb483c7efb591876",
"url": "https://api.github.com/repos/joomla-framework/event/zipball/9092ee2dc3fd010c7759c4467a93397c1dac8026",
"reference": "9092ee2dc3fd010c7759c4467a93397c1dac8026",
"shasum": ""
},
"require": {
@ -813,7 +818,7 @@
"joomla/coding-standards": "~2.0@alpha",
"phpunit/phpunit": "~6.3"
},
"time": "2018-02-10T16:18:57+00:00",
"time": "2018-04-10T05:22:19+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -891,17 +896,17 @@
},
{
"name": "joomla/filter",
"version": "1.3.3",
"version_normalized": "1.3.3.0",
"version": "1.3.5",
"version_normalized": "1.3.5.0",
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/filter.git",
"reference": "1ee770b83790c02d0fbcef77ad0647153e1faf74"
"reference": "ee1d870b5c188056745e1dd3cece21522e2158b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/filter/zipball/1ee770b83790c02d0fbcef77ad0647153e1faf74",
"reference": "1ee770b83790c02d0fbcef77ad0647153e1faf74",
"url": "https://api.github.com/repos/joomla-framework/filter/zipball/ee1d870b5c188056745e1dd3cece21522e2158b8",
"reference": "ee1d870b5c188056745e1dd3cece21522e2158b8",
"shasum": ""
},
"require": {
@ -909,14 +914,14 @@
"php": "^5.3.10|~7.0"
},
"require-dev": {
"joomla/coding-standards": "~2.0@alpha",
"joomla/language": "~1.3",
"phpunit/phpunit": "^4.8.35|^5.4.3|~6.0",
"squizlabs/php_codesniffer": "1.*"
"phpunit/phpunit": "^4.8.35|^5.4.3|~6.0"
},
"suggest": {
"joomla/language": "Required only if you want to use `OutputFilter::stringURLSafe`."
},
"time": "2017-07-04T15:07:30+00:00",
"time": "2018-05-26T15:48:53+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -931,7 +936,7 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
"GPL-2.0-or-later"
],
"description": "Joomla Filter Package",
"homepage": "https://github.com/joomla-framework/filter",
@ -1003,12 +1008,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/image.git",
"reference": "20cf764c62927364ce40478e55b7d6c09581f079"
"reference": "0222c4a6dba784ea05715d8c060911cb57091953"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/image/zipball/20cf764c62927364ce40478e55b7d6c09581f079",
"reference": "20cf764c62927364ce40478e55b7d6c09581f079",
"url": "https://api.github.com/repos/joomla-framework/image/zipball/0222c4a6dba784ea05715d8c060911cb57091953",
"reference": "0222c4a6dba784ea05715d8c060911cb57091953",
"shasum": ""
},
"require": {
@ -1021,7 +1026,7 @@
"joomla/test": "~1.0",
"phpunit/phpunit": "~6.3"
},
"time": "2018-02-18T19:04:48+00:00",
"time": "2018-05-25T02:30:04+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -1048,17 +1053,17 @@
},
{
"name": "joomla/input",
"version": "1.2.1",
"version_normalized": "1.2.1.0",
"version": "1.2.3",
"version_normalized": "1.2.3.0",
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/input.git",
"reference": "8244ff30aeccd855d91b4e9d276cb2d3d6802008"
"reference": "ff97c08aa5fa0f48ccc3e7444827f7f9a6b904c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/input/zipball/8244ff30aeccd855d91b4e9d276cb2d3d6802008",
"reference": "8244ff30aeccd855d91b4e9d276cb2d3d6802008",
"url": "https://api.github.com/repos/joomla-framework/input/zipball/ff97c08aa5fa0f48ccc3e7444827f7f9a6b904c8",
"reference": "ff97c08aa5fa0f48ccc3e7444827f7f9a6b904c8",
"shasum": ""
},
"require": {
@ -1070,7 +1075,7 @@
"joomla/test": "~1.0",
"phpunit/phpunit": "^4.8.35|^5.4.3|~6.0"
},
"time": "2018-03-15T00:08:30+00:00",
"time": "2018-05-26T17:08:08+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -1102,12 +1107,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/ldap.git",
"reference": "19f504133108dc84b31872014f5a961e683b35b4"
"reference": "f19a37a05c21fd197688aedcb67489ca7346695c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/ldap/zipball/19f504133108dc84b31872014f5a961e683b35b4",
"reference": "19f504133108dc84b31872014f5a961e683b35b4",
"url": "https://api.github.com/repos/joomla-framework/ldap/zipball/f19a37a05c21fd197688aedcb67489ca7346695c",
"reference": "f19a37a05c21fd197688aedcb67489ca7346695c",
"shasum": ""
},
"require": {
@ -1119,7 +1124,7 @@
"joomla/registry": "^1.4.5|~2.0",
"phpunit/phpunit": "~6.3"
},
"time": "2018-02-18T19:25:51+00:00",
"time": "2018-05-25T02:31:33+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -1257,12 +1262,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/registry.git",
"reference": "5b32d71ad57bc87943f98c00c980e25381e947e6"
"reference": "d6f0d054668f5daece36787e8158c317f90a2a2d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/5b32d71ad57bc87943f98c00c980e25381e947e6",
"reference": "5b32d71ad57bc87943f98c00c980e25381e947e6",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/d6f0d054668f5daece36787e8158c317f90a2a2d",
"reference": "d6f0d054668f5daece36787e8158c317f90a2a2d",
"shasum": ""
},
"require": {
@ -1277,7 +1282,7 @@
"suggest": {
"symfony/yaml": "Install symfony/yaml if you require YAML support."
},
"time": "2018-03-18T21:29:51+00:00",
"time": "2018-06-15T12:02:26+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -1309,12 +1314,12 @@
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/session.git",
"reference": "f7cca05d546fb12da488e42a753b703bf51c63a7"
"reference": "8dd621956f33461ea8d6ca590f0fcc83bb20ed9e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/session/zipball/f7cca05d546fb12da488e42a753b703bf51c63a7",
"reference": "f7cca05d546fb12da488e42a753b703bf51c63a7",
"url": "https://api.github.com/repos/joomla-framework/session/zipball/8dd621956f33461ea8d6ca590f0fcc83bb20ed9e",
"reference": "8dd621956f33461ea8d6ca590f0fcc83bb20ed9e",
"shasum": ""
},
"require": {
@ -1338,7 +1343,7 @@
"joomla/event": "The joomla/event package is required to use Joomla\\Session\\Session.",
"joomla/input": "The joomla/input package is required to use Address and Forwarded session validators."
},
"time": "2018-05-13T22:56:54+00:00",
"time": "2018-06-18T03:30:21+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
@ -1582,17 +1587,17 @@
},
{
"name": "paragonie/random_compat",
"version": "v2.0.12",
"version_normalized": "2.0.12.0",
"version": "v2.0.15",
"version_normalized": "2.0.15.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "258c89a6b97de7dfaf5b8c7607d0478e236b04fb"
"reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/258c89a6b97de7dfaf5b8c7607d0478e236b04fb",
"reference": "258c89a6b97de7dfaf5b8c7607d0478e236b04fb",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/10bcb46e8f3d365170f6de9d05245aa066b81f09",
"reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09",
"shasum": ""
},
"require": {
@ -1604,7 +1609,7 @@
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"time": "2018-04-04T21:24:14+00:00",
"time": "2018-06-08T15:26:40+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1626,27 +1631,28 @@
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
]
},
{
"name": "paragonie/sodium_compat",
"version": "v1.6.1",
"version_normalized": "1.6.1.0",
"version": "v1.6.3",
"version_normalized": "1.6.3.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/sodium_compat.git",
"reference": "9857e17bf9c1464485d8cc804eb13f2bcddc4cf0"
"reference": "7d0549c3947eaea620f4e523f42ab236cf7fd304"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/9857e17bf9c1464485d8cc804eb13f2bcddc4cf0",
"reference": "9857e17bf9c1464485d8cc804eb13f2bcddc4cf0",
"url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/7d0549c3947eaea620f4e523f42ab236cf7fd304",
"reference": "7d0549c3947eaea620f4e523f42ab236cf7fd304",
"shasum": ""
},
"require": {
"paragonie/random_compat": "^1|^2",
"paragonie/random_compat": ">=1",
"php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7"
},
"require-dev": {
@ -1656,7 +1662,7 @@
"ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.",
"ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security."
},
"time": "2018-03-21T17:08:08+00:00",
"time": "2018-06-06T17:30:29+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1987,17 +1993,17 @@
},
{
"name": "symfony/console",
"version": "v3.4.7",
"version_normalized": "3.4.7.0",
"version": "v3.4.11",
"version_normalized": "3.4.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf"
"reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf",
"reference": "d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf",
"url": "https://api.github.com/repos/symfony/console/zipball/36f83f642443c46f3cf751d4d2ee5d047d757a27",
"reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27",
"shasum": ""
},
"require": {
@ -2018,12 +2024,12 @@
"symfony/process": "~3.3|~4.0"
},
"suggest": {
"psr/log": "For using the console logger",
"psr/log-implementation": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
},
"time": "2018-04-03T05:22:50+00:00",
"time": "2018-05-16T08:49:21+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2058,17 +2064,17 @@
},
{
"name": "symfony/debug",
"version": "v3.4.7",
"version_normalized": "3.4.7.0",
"version": "v3.4.11",
"version_normalized": "3.4.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "9cf7c2271cfb89ef9727db1b740ca77be57bf9d7"
"reference": "b28fd73fefbac341f673f5efd707d539d6a19f68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/9cf7c2271cfb89ef9727db1b740ca77be57bf9d7",
"reference": "9cf7c2271cfb89ef9727db1b740ca77be57bf9d7",
"url": "https://api.github.com/repos/symfony/debug/zipball/b28fd73fefbac341f673f5efd707d539d6a19f68",
"reference": "b28fd73fefbac341f673f5efd707d539d6a19f68",
"shasum": ""
},
"require": {
@ -2081,7 +2087,7 @@
"require-dev": {
"symfony/http-kernel": "~2.8|~3.0|~4.0"
},
"time": "2018-04-03T05:22:50+00:00",
"time": "2018-05-16T14:03:39+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2229,18 +2235,75 @@
]
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.7.0",
"version_normalized": "1.7.0.0",
"name": "symfony/polyfill-ctype",
"version": "v1.8.0",
"version_normalized": "1.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"time": "2018-04-30T19:57:29+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
]
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.8.0",
"version_normalized": "1.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
"shasum": ""
},
"require": {
@ -2249,11 +2312,11 @@
"suggest": {
"ext-mbstring": "For best performance"
},
"time": "2018-01-30T19:27:44+00:00",
"time": "2018-04-26T10:06:28+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
"dev-master": "1.8-dev"
}
},
"installation-source": "dist",
@ -2403,8 +2466,8 @@
},
{
"name": "symfony/web-link",
"version": "v3.4.7",
"version_normalized": "3.4.7.0",
"version": "v3.4.11",
"version_normalized": "3.4.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/web-link.git",
@ -2476,21 +2539,22 @@
},
{
"name": "symfony/yaml",
"version": "v3.4.7",
"version_normalized": "3.4.7.0",
"version": "v3.4.11",
"version_normalized": "3.4.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "a42f9da85c7c38d59f5e53f076fe81a091f894d0"
"reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/a42f9da85c7c38d59f5e53f076fe81a091f894d0",
"reference": "a42f9da85c7c38d59f5e53f076fe81a091f894d0",
"url": "https://api.github.com/repos/symfony/yaml/zipball/c5010cc1692ce1fa328b1fb666961eb3d4a85bb0",
"reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
"php": "^5.5.9|>=7.0.8",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
@ -2501,7 +2565,7 @@
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"time": "2018-04-03T05:14:20+00:00",
"time": "2018-05-03T23:18:14+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2536,17 +2600,17 @@
},
{
"name": "zendframework/zend-diactoros",
"version": "1.7.1",
"version_normalized": "1.7.1.0",
"version": "1.7.2",
"version_normalized": "1.7.2.0",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-diactoros.git",
"reference": "bf26aff803a11c5cc8eb7c4878a702c403ec67f1"
"reference": "741e7a571836f038de731105f4742ca8a164e43a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/bf26aff803a11c5cc8eb7c4878a702c403ec67f1",
"reference": "bf26aff803a11c5cc8eb7c4878a702c403ec67f1",
"url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/741e7a571836f038de731105f4742ca8a164e43a",
"reference": "741e7a571836f038de731105f4742ca8a164e43a",
"shasum": ""
},
"require": {
@ -2562,12 +2626,13 @@
"phpunit/phpunit": "^5.7.16 || ^6.0.8",
"zendframework/zend-coding-standard": "~1.0"
},
"time": "2018-02-26T15:44:50+00:00",
"time": "2018-05-29T16:53:08+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7.x-dev",
"dev-develop": "1.8.x-dev"
"dev-develop": "1.8.x-dev",
"dev-release-2.0": "2.0.x-dev"
}
},
"installation-source": "dist",

View File

@ -45,32 +45,31 @@ final class Core
* @throws Ex\EnvironmentIsBrokenException
*
* @return string
*
* @psalm-suppress RedundantCondition - It's valid to use is_int to check for overflow.
*/
public static function incrementCounter($ctr, $inc)
{
if (Core::ourStrlen($ctr) !== Core::BLOCK_BYTE_SIZE) {
throw new Ex\EnvironmentIsBrokenException(
'Trying to increment a nonce of the wrong size.'
);
}
Core::ensureTrue(
Core::ourStrlen($ctr) === Core::BLOCK_BYTE_SIZE,
'Trying to increment a nonce of the wrong size.'
);
if (! \is_int($inc)) {
throw new Ex\EnvironmentIsBrokenException(
'Trying to increment nonce by a non-integer.'
);
}
Core::ensureTrue(
\is_int($inc),
'Trying to increment nonce by a non-integer.'
);
if ($inc < 0) {
throw new Ex\EnvironmentIsBrokenException(
'Trying to increment nonce by a negative amount.'
);
}
// The caller is probably re-using CTR-mode keystream if they increment by 0.
Core::ensureTrue(
$inc > 0,
'Trying to increment a nonce by a nonpositive amount'
);
if ($inc > PHP_INT_MAX - 255) {
throw new Ex\EnvironmentIsBrokenException(
'Integer overflow may occur.'
);
}
Core::ensureTrue(
$inc <= PHP_INT_MAX - 255,
'Integer overflow may occur'
);
/*
* We start at the rightmost byte (big-endian)
@ -80,11 +79,7 @@ final class Core
$sum = \ord($ctr[$i]) + $inc;
/* Detect integer overflow and fail. */
if (! \is_int($sum)) {
throw new Ex\EnvironmentIsBrokenException(
'Integer overflow in CTR mode nonce increment.'
);
}
Core::ensureTrue(\is_int($sum), 'Integer overflow in CTR mode nonce increment');
$ctr[$i] = \pack('C', $sum & 0xFF);
$inc = $sum >> 8;
@ -135,18 +130,19 @@ final class Core
$nativeHKDF = \is_callable('\\hash_hkdf');
}
if ($nativeHKDF) {
if (\is_null($salt)) {
$salt = '';
}
return \hash_hkdf($hash, $ikm, $length, $info, $salt);
}
$digest_length = Core::ourStrlen(\hash_hmac($hash, '', '', true));
// Sanity-check the desired output length.
if (empty($length) || ! \is_int($length) ||
$length < 0 || $length > 255 * $digest_length) {
throw new Ex\EnvironmentIsBrokenException(
'Bad output length requested of HKDF.'
);
}
Core::ensureTrue(
!empty($length) && \is_int($length) && $length >= 0 && $length <= 255 * $digest_length,
'Bad output length requested of HDKF.'
);
// "if [salt] not provided, is set to a string of HashLen zeroes."
if (\is_null($salt)) {
@ -161,9 +157,7 @@ final class Core
// HKDF-Expand:
// This check is useless, but it serves as a reminder to the spec.
if (Core::ourStrlen($prk) < $digest_length) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(Core::ourStrlen($prk) >= $digest_length);
// T(0) = ''
$t = '';
@ -183,9 +177,7 @@ final class Core
// ORM = first L octets of T
/** @var string $orm */
$orm = Core::ourSubstr($t, 0, $length);
if (!\is_string($orm)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($orm));
return $orm;
}
@ -219,9 +211,7 @@ final class Core
// We're not attempting to make variable-length string comparison
// secure, as that's very difficult. Make sure the strings are the same
// length.
if (Core::ourStrlen($expected) !== Core::ourStrlen($given)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(Core::ourStrlen($expected) === Core::ourStrlen($given));
$blind = Core::secureRandom(32);
$message_compare = \hash_hmac(Core::HASH_FUNCTION_NAME, $given, $blind);
@ -238,9 +228,7 @@ final class Core
*/
public static function ensureConstantExists($name)
{
if (! \defined($name)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\defined($name));
}
/**
@ -253,8 +241,22 @@ final class Core
*/
public static function ensureFunctionExists($name)
{
if (! \function_exists($name)) {
throw new Ex\EnvironmentIsBrokenException();
Core::ensureTrue(\function_exists($name));
}
/**
* Throws an exception if the condition is false.
*
* @param bool $condition
* @param string $message
* @return void
*
* @throws Ex\EnvironmentIsBrokenException
*/
public static function ensureTrue($condition, $message = '')
{
if (!$condition) {
throw new Ex\EnvironmentIsBrokenException($message);
}
}
@ -277,13 +279,11 @@ final class Core
{
static $exists = null;
if ($exists === null) {
$exists = \function_exists('mb_strlen');
$exists = \extension_loaded('mbstring') && \ini_get('mbstring.func_overload') !== false && (int)\ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING;
}
if ($exists) {
$length = \mb_strlen($str, '8bit');
if ($length === false) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($length !== false);
return $length;
} else {
return \strlen($str);
@ -305,33 +305,46 @@ final class Core
{
static $exists = null;
if ($exists === null) {
$exists = \function_exists('mb_substr');
$exists = \extension_loaded('mbstring') && \ini_get('mbstring.func_overload') !== false && (int)\ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING;
}
// This is required to make mb_substr behavior identical to substr.
// Without this, mb_substr() would return false, contra to what the
// PHP documentation says (it doesn't say it can return false.)
$input_len = Core::ourStrlen($str);
if ($start === $input_len && !$length) {
return '';
}
if ($start > $input_len) {
return false;
}
// mb_substr($str, 0, NULL, '8bit') returns an empty string on PHP 5.3,
// so we have to find the length ourselves. Also, substr() doesn't
// accept null for the length.
if (! isset($length)) {
if ($start >= 0) {
$length = $input_len - $start;
} else {
$length = -$start;
}
}
if ($length < 0) {
throw new \InvalidArgumentException(
"Negative lengths are not supported with ourSubstr."
);
}
if ($exists) {
// mb_substr($str, 0, NULL, '8bit') returns an empty string on PHP
// 5.3, so we have to find the length ourselves.
if (! isset($length)) {
if ($start >= 0) {
$length = Core::ourStrlen($str) - $start;
} else {
$length = -$start;
}
}
// This is required to make mb_substr behavior identical to substr.
// Without this, mb_substr() would return false, contra to what the
// PHP documentation says (it doesn't say it can return false.)
if ($start === Core::ourStrlen($str) && $length === 0) {
return '';
}
if ($start > Core::ourStrlen($str)) {
return false;
}
$substr = \mb_substr($str, $start, $length, '8bit');
if (Core::ourStrlen($substr) !== $length) {
// At this point there are two cases where mb_substr can
// legitimately return an empty string. Either $length is 0, or
// $start is equal to the length of the string (both mb_substr and
// substr return an empty string when this happens). It should never
// ever return a string that's longer than $length.
if (Core::ourStrlen($substr) > $length || (Core::ourStrlen($substr) === 0 && $length !== 0 && $start !== $input_len)) {
throw new Ex\EnvironmentIsBrokenException(
'Your version of PHP has bug #66797. Its implementation of
mb_substr() is incorrect. See the details here:
@ -341,12 +354,7 @@ final class Core
return $substr;
}
// Unlike mb_substr(), substr() doesn't accept NULL for length
if (isset($length)) {
return \substr($str, $start, $length);
} else {
return \substr($str, $start);
}
return \substr($str, $start, $length);
}
/**
@ -390,28 +398,22 @@ final class Core
$key_length += 0;
$algorithm = \strtolower($algorithm);
if (! \in_array($algorithm, \hash_algos(), true)) {
throw new Ex\EnvironmentIsBrokenException(
'Invalid or unsupported hash algorithm.'
);
}
Core::ensureTrue(
\in_array($algorithm, \hash_algos(), true),
'Invalid or unsupported hash algorithm.'
);
// Whitelist, or we could end up with people using CRC32.
$ok_algorithms = [
'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
'ripemd160', 'ripemd256', 'ripemd320', 'whirlpool',
];
if (! \in_array($algorithm, $ok_algorithms, true)) {
throw new Ex\EnvironmentIsBrokenException(
'Algorithm is not a secure cryptographic hash function.'
);
}
Core::ensureTrue(
\in_array($algorithm, $ok_algorithms, true),
'Algorithm is not a secure cryptographic hash function.'
);
if ($count <= 0 || $key_length <= 0) {
throw new Ex\EnvironmentIsBrokenException(
'Invalid PBKDF2 parameters.'
);
}
Core::ensureTrue($count > 0 && $key_length > 0, 'Invalid PBKDF2 parameters.');
if (\function_exists('hash_pbkdf2')) {
// The output length is in NIBBLES (4-bits) if $raw_output is false!

View File

@ -14,11 +14,27 @@ class Crypto
* @param bool $raw_binary
*
* @throws Ex\EnvironmentIsBrokenException
* @throws \TypeError
*
* @return string
*/
public static function encrypt($plaintext, Key $key, $raw_binary = false)
public static function encrypt($plaintext, $key, $raw_binary = false)
{
if (!\is_string($plaintext)) {
throw new \TypeError(
'String expected for argument 1. ' . \ucfirst(\gettype($plaintext)) . ' given instead.'
);
}
if (!($key instanceof Key)) {
throw new \TypeError(
'Key expected for argument 2. ' . \ucfirst(\gettype($key)) . ' given instead.'
);
}
if (!\is_bool($raw_binary)) {
throw new \TypeError(
'Boolean expected for argument 3. ' . \ucfirst(\gettype($raw_binary)) . ' given instead.'
);
}
return self::encryptInternal(
$plaintext,
KeyOrPassword::createFromKey($key),
@ -35,11 +51,27 @@ class Crypto
* @param bool $raw_binary
*
* @throws Ex\EnvironmentIsBrokenException
* @throws \TypeError
*
* @return string
*/
public static function encryptWithPassword($plaintext, $password, $raw_binary = false)
{
if (!\is_string($plaintext)) {
throw new \TypeError(
'String expected for argument 1. ' . \ucfirst(\gettype($plaintext)) . ' given instead.'
);
}
if (!\is_string($password)) {
throw new \TypeError(
'String expected for argument 2. ' . \ucfirst(\gettype($password)) . ' given instead.'
);
}
if (!\is_bool($raw_binary)) {
throw new \TypeError(
'Boolean expected for argument 3. ' . \ucfirst(\gettype($raw_binary)) . ' given instead.'
);
}
return self::encryptInternal(
$plaintext,
KeyOrPassword::createFromPassword($password),
@ -54,13 +86,29 @@ class Crypto
* @param Key $key
* @param bool $raw_binary
*
* @throws \TypeError
* @throws Ex\EnvironmentIsBrokenException
* @throws Ex\WrongKeyOrModifiedCiphertextException
*
* @return string
*/
public static function decrypt($ciphertext, Key $key, $raw_binary = false)
public static function decrypt($ciphertext, $key, $raw_binary = false)
{
if (!\is_string($ciphertext)) {
throw new \TypeError(
'String expected for argument 1. ' . \ucfirst(\gettype($ciphertext)) . ' given instead.'
);
}
if (!($key instanceof Key)) {
throw new \TypeError(
'Key expected for argument 2. ' . \ucfirst(\gettype($key)) . ' given instead.'
);
}
if (!\is_bool($raw_binary)) {
throw new \TypeError(
'Boolean expected for argument 3. ' . \ucfirst(\gettype($raw_binary)) . ' given instead.'
);
}
return self::decryptInternal(
$ciphertext,
KeyOrPassword::createFromKey($key),
@ -78,11 +126,27 @@ class Crypto
*
* @throws Ex\EnvironmentIsBrokenException
* @throws Ex\WrongKeyOrModifiedCiphertextException
* @throws \TypeError
*
* @return string
*/
public static function decryptWithPassword($ciphertext, $password, $raw_binary = false)
{
if (!\is_string($ciphertext)) {
throw new \TypeError(
'String expected for argument 1. ' . \ucfirst(\gettype($ciphertext)) . ' given instead.'
);
}
if (!\is_string($password)) {
throw new \TypeError(
'String expected for argument 2. ' . \ucfirst(\gettype($password)) . ' given instead.'
);
}
if (!\is_bool($raw_binary)) {
throw new \TypeError(
'Boolean expected for argument 3. ' . \ucfirst(\gettype($raw_binary)) . ' given instead.'
);
}
return self::decryptInternal(
$ciphertext,
KeyOrPassword::createFromPassword($password),
@ -98,11 +162,23 @@ class Crypto
*
* @throws Ex\EnvironmentIsBrokenException
* @throws Ex\WrongKeyOrModifiedCiphertextException
* @throws \TypeError
*
* @return string
*/
public static function legacyDecrypt($ciphertext, $key)
{
if (!\is_string($ciphertext)) {
throw new \TypeError(
'String expected for argument 1. ' . \ucfirst(\gettype($ciphertext)) . ' given instead.'
);
}
if (!\is_string($key)) {
throw new \TypeError(
'String expected for argument 2. ' . \ucfirst(\gettype($key)) . ' given instead.'
);
}
RuntimeTests::runtimeTest();
// Extract the HMAC from the front of the ciphertext.
@ -115,16 +191,12 @@ class Crypto
* @var string
*/
$hmac = Core::ourSubstr($ciphertext, 0, Core::LEGACY_MAC_BYTE_SIZE);
if (!\is_string($hmac)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($hmac));
/**
* @var string
*/
$ciphertext = Core::ourSubstr($ciphertext, Core::LEGACY_MAC_BYTE_SIZE);
if (!\is_string($ciphertext)) {
throw new Ex\EnvironmentIsBrokenException();
}
$messageCiphertext = Core::ourSubstr($ciphertext, Core::LEGACY_MAC_BYTE_SIZE);
Core::ensureTrue(\is_string($messageCiphertext));
// Regenerate the same authentication sub-key.
$akey = Core::HKDF(
@ -135,7 +207,7 @@ class Crypto
null
);
if (self::verifyHMAC($hmac, $ciphertext, $akey)) {
if (self::verifyHMAC($hmac, $messageCiphertext, $akey)) {
// Regenerate the same encryption sub-key.
$ekey = Core::HKDF(
Core::LEGACY_HASH_FUNCTION_NAME,
@ -146,7 +218,7 @@ class Crypto
);
// Extract the IV from the ciphertext.
if (Core::ourStrlen($ciphertext) <= Core::LEGACY_BLOCK_BYTE_SIZE) {
if (Core::ourStrlen($messageCiphertext) <= Core::LEGACY_BLOCK_BYTE_SIZE) {
throw new Ex\WrongKeyOrModifiedCiphertextException(
'Ciphertext is too short.'
);
@ -154,18 +226,14 @@ class Crypto
/**
* @var string
*/
$iv = Core::ourSubstr($ciphertext, 0, Core::LEGACY_BLOCK_BYTE_SIZE);
if (!\is_string($iv)) {
throw new Ex\EnvironmentIsBrokenException();
}
$iv = Core::ourSubstr($messageCiphertext, 0, Core::LEGACY_BLOCK_BYTE_SIZE);
Core::ensureTrue(\is_string($iv));
/**
* @var string
*/
$actualCiphertext = Core::ourSubstr($ciphertext, Core::LEGACY_BLOCK_BYTE_SIZE);
if (!\is_string($actualCiphertext)) {
throw new Ex\EnvironmentIsBrokenException();
}
$actualCiphertext = Core::ourSubstr($messageCiphertext, Core::LEGACY_BLOCK_BYTE_SIZE);
Core::ensureTrue(\is_string($actualCiphertext));
// Do the decryption.
$plaintext = self::plainDecrypt($actualCiphertext, $ekey, $iv, Core::LEGACY_CIPHER_METHOD);
@ -254,9 +322,7 @@ class Crypto
Core::HEADER_VERSION_SIZE,
Core::SALT_BYTE_SIZE
);
if (!\is_string($salt)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($salt));
// Get the IV.
/** @var string $iv */
@ -265,9 +331,7 @@ class Crypto
Core::HEADER_VERSION_SIZE + Core::SALT_BYTE_SIZE,
Core::BLOCK_BYTE_SIZE
);
if (!\is_string($iv)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($iv));
// Get the HMAC.
/** @var string $hmac */
@ -276,9 +340,7 @@ class Crypto
Core::ourStrlen($ciphertext) - Core::MAC_BYTE_SIZE,
Core::MAC_BYTE_SIZE
);
if (!\is_string($hmac)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($hmac));
// Get the actual encrypted ciphertext.
/** @var string $encrypted */
@ -289,9 +351,7 @@ class Crypto
Core::ourStrlen($ciphertext) - Core::MAC_BYTE_SIZE - Core::SALT_BYTE_SIZE -
Core::BLOCK_BYTE_SIZE - Core::HEADER_VERSION_SIZE
);
if (!\is_string($encrypted)) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(\is_string($encrypted));
// Derive the separate encryption and authentication keys from the key
// or password, whichever it is.
@ -331,11 +391,7 @@ class Crypto
$iv
);
if (!\is_string($ciphertext)) {
throw new Ex\EnvironmentIsBrokenException(
'openssl_encrypt() failed.'
);
}
Core::ensureTrue(\is_string($ciphertext), 'openssl_encrypt() failed');
return $ciphertext;
}
@ -365,11 +421,7 @@ class Crypto
OPENSSL_RAW_DATA,
$iv
);
if (!\is_string($plaintext)) {
throw new Ex\EnvironmentIsBrokenException(
'openssl_decrypt() failed.'
);
}
Core::ensureTrue(\is_string($plaintext), 'openssl_decrypt() failed.');
return $plaintext;
}

View File

@ -178,11 +178,10 @@ final class Encoding
{
// Headers must be a constant length to prevent one type's header from
// being a prefix of another type's header, leading to ambiguity.
if (Core::ourStrlen($header) !== self::SERIALIZE_HEADER_BYTES) {
throw new Ex\EnvironmentIsBrokenException(
'Header must be ' . self::SERIALIZE_HEADER_BYTES . ' bytes.'
);
}
Core::ensureTrue(
Core::ourStrlen($header) === self::SERIALIZE_HEADER_BYTES,
'Header must be ' . self::SERIALIZE_HEADER_BYTES . ' bytes.'
);
return Encoding::binToHex(
$header .
@ -211,11 +210,10 @@ final class Encoding
{
// Headers must be a constant length to prevent one type's header from
// being a prefix of another type's header, leading to ambiguity.
if (Core::ourStrlen($expected_header) !== self::SERIALIZE_HEADER_BYTES) {
throw new Ex\EnvironmentIsBrokenException(
'Header must be 4 bytes.'
);
}
Core::ensureTrue(
Core::ourStrlen($expected_header) === self::SERIALIZE_HEADER_BYTES,
'Header must be 4 bytes.'
);
/* If you get an exception here when attempting to load from a file, first pass your
key to Encoding::trimTrailingWhitespace() to remove newline characters, etc. */

View File

@ -348,11 +348,10 @@ final class File
/* Initialize a streaming HMAC state. */
/** @var resource $hmac */
$hmac = \hash_init(Core::HASH_FUNCTION_NAME, HASH_HMAC, $akey);
if (!\is_resource($hmac)) {
throw new Ex\EnvironmentIsBrokenException(
'Cannot initialize a hash context'
);
}
Core::ensureTrue(
\is_resource($hmac) || \is_object($hmac),
'Cannot initialize a hash context'
);
/* Write the header, salt, and IV. */
self::writeBytes(
@ -407,11 +406,7 @@ final class File
$thisIv
);
if (!\is_string($encrypted)) {
throw new Ex\EnvironmentIsBrokenException(
'OpenSSL encryption error'
);
}
Core::ensureTrue(\is_string($encrypted), 'OpenSSL encryption error');
/* Write this buffer's ciphertext. */
self::writeBytes($outputHandle, $encrypted, Core::ourStrlen($encrypted));
@ -518,11 +513,7 @@ final class File
/* Initialize a streaming HMAC state. */
/** @var resource $hmac */
$hmac = \hash_init(Core::HASH_FUNCTION_NAME, HASH_HMAC, $akey);
if (!\is_resource($hmac)) {
throw new Ex\EnvironmentIsBrokenException(
'Cannot initialize a hash context'
);
}
Core::ensureTrue(\is_resource($hmac) || \is_object($hmac), 'Cannot initialize a hash context');
/* Reset file pointer to the beginning of the file after the header */
if (\fseek($inputHandle, Core::HEADER_VERSION_SIZE, SEEK_SET) === false) {
@ -576,11 +567,7 @@ final class File
/* Remember this buffer-sized chunk's HMAC. */
/** @var resource $chunk_mac */
$chunk_mac = \hash_copy($hmac);
if (!\is_resource($chunk_mac)) {
throw new Ex\EnvironmentIsBrokenException(
'Cannot duplicate a hash context'
);
}
Core::ensureTrue(\is_resource($chunk_mac) || \is_object($chunk_mac), 'Cannot duplicate a hash context');
$macs []= \hash_final($chunk_mac);
}
@ -634,11 +621,7 @@ final class File
\hash_update($hmac2, $read);
/** @var resource $calc_mac */
$calc_mac = \hash_copy($hmac2);
if (!\is_resource($calc_mac)) {
throw new Ex\EnvironmentIsBrokenException(
'Cannot duplicate a hash context'
);
}
Core::ensureTrue(\is_resource($calc_mac) || \is_object($calc_mac), 'Cannot duplicate a hash context');
$calc = \hash_final($calc_mac);
if (empty($macs)) {
@ -660,11 +643,7 @@ final class File
OPENSSL_RAW_DATA,
$thisIv
);
if (!\is_string($decrypted)) {
throw new Ex\EnvironmentIsBrokenException(
'OpenSSL decryption error'
);
}
Core::ensureTrue(\is_string($decrypted), 'OpenSSL decryption error');
/* Write the plaintext to the output file. */
self::writeBytes(
@ -696,13 +675,12 @@ final class File
*/
public static function readBytes($stream, $num_bytes)
{
if ($num_bytes < 0) {
throw new Ex\EnvironmentIsBrokenException(
'Tried to read less than 0 bytes'
);
} elseif ($num_bytes === 0) {
Core::ensureTrue($num_bytes >= 0, 'Tried to read less than 0 bytes');
if ($num_bytes === 0) {
return '';
}
$buf = '';
$remaining = $num_bytes;
while ($remaining > 0 && ! \feof($stream)) {

View File

@ -84,11 +84,10 @@ final class Key
*/
private function __construct($bytes)
{
if (Core::ourStrlen($bytes) !== self::KEY_BYTE_SIZE) {
throw new Ex\EnvironmentIsBrokenException(
'Bad key length.'
);
}
Core::ensureTrue(
Core::ourStrlen($bytes) === self::KEY_BYTE_SIZE,
'Bad key length.'
);
$this->key_bytes = $bytes;
}

View File

@ -57,14 +57,16 @@ final class KeyOrPassword
*/
public function deriveKeys($salt)
{
if (Core::ourStrlen($salt) !== Core::SALT_BYTE_SIZE) {
throw new Ex\EnvironmentIsBrokenException('Bad salt.');
}
Core::ensureTrue(
Core::ourStrlen($salt) === Core::SALT_BYTE_SIZE,
'Bad salt.'
);
if ($this->secret_type === self::SECRET_TYPE_KEY) {
if (!($this->secret instanceof Key)) {
throw new Ex\CryptoException('Expected a Key object');
}
Core::ensureTrue($this->secret instanceof Key);
/**
* @psalm-suppress PossiblyInvalidMethodCall
*/
$akey = Core::HKDF(
Core::HASH_FUNCTION_NAME,
$this->secret->getRawBytes(),
@ -72,6 +74,9 @@ final class KeyOrPassword
Core::AUTHENTICATION_INFO_STRING,
$salt
);
/**
* @psalm-suppress PossiblyInvalidMethodCall
*/
$ekey = Core::HKDF(
Core::HASH_FUNCTION_NAME,
$this->secret->getRawBytes(),
@ -81,15 +86,18 @@ final class KeyOrPassword
);
return new DerivedKeys($akey, $ekey);
} elseif ($this->secret_type === self::SECRET_TYPE_PASSWORD) {
if (!\is_string($this->secret)) {
throw new Ex\CryptoException('Expected a string');
}
Core::ensureTrue(\is_string($this->secret));
/* Our PBKDF2 polyfill is vulnerable to a DoS attack documented in
* GitHub issue #230. The fix is to pre-hash the password to ensure
* it is short. We do the prehashing here instead of in pbkdf2() so
* that pbkdf2() still computes the function as defined by the
* standard. */
/**
* @psalm-suppress PossiblyInvalidArgument
*/
$prehash = \hash(Core::HASH_FUNCTION_NAME, $this->secret, true);
$prekey = Core::pbkdf2(
Core::HASH_FUNCTION_NAME,
$prehash,
@ -127,6 +135,14 @@ final class KeyOrPassword
*/
private function __construct($secret_type, $secret)
{
// The constructor is private, so these should never throw.
if ($secret_type === self::SECRET_TYPE_KEY) {
Core::ensureTrue($secret instanceof Key);
} elseif ($secret_type === self::SECRET_TYPE_PASSWORD) {
Core::ensureTrue(\is_string($secret));
} else {
throw new Ex\EnvironmentIsBrokenException('Bad secret type.');
}
$this->secret_type = $secret_type;
$this->secret = $secret;
}

View File

@ -79,6 +79,7 @@ final class KeyProtectedByPassword
* @throws Ex\EnvironmentIsBrokenException
* @throws Ex\WrongKeyOrModifiedCiphertextException
*
* @param string $password
* @return Key
*/
public function unlockKey($password)
@ -103,6 +104,35 @@ final class KeyProtectedByPassword
}
}
/**
* Changes the password.
*
* @param string $current_password
* @param string $new_password
*
* @throws Ex\EnvironmentIsBrokenException
* @throws Ex\WrongKeyOrModifiedCiphertextException
*
* @return KeyProtectedByPassword
*/
public function changePassword($current_password, $new_password)
{
$inner_key = $this->unlockKey($current_password);
/* The password is hashed as a form of poor-man's domain separation
* between this use of encryptWithPassword() and other uses of
* encryptWithPassword() that the user may also be using as part of the
* same protocol. */
$encrypted_key = Crypto::encryptWithPassword(
$inner_key->saveToAsciiSafeString(),
\hash(Core::HASH_FUNCTION_NAME, $new_password, true),
true
);
$this->encrypted_key = $encrypted_key;
return $this;
}
/**
* Constructor for KeyProtectedByPassword.
*

View File

@ -59,13 +59,9 @@ class RuntimeTests extends Crypto
RuntimeTests::HKDFTestVector();
RuntimeTests::testEncryptDecrypt();
if (Core::ourStrlen(Key::createNewRandomKey()->getRawBytes()) != Core::KEY_BYTE_SIZE) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(Core::ourStrlen(Key::createNewRandomKey()->getRawBytes()) === Core::KEY_BYTE_SIZE);
if (Core::ENCRYPTION_INFO_STRING == Core::AUTHENTICATION_INFO_STRING) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(Core::ENCRYPTION_INFO_STRING !== Core::AUTHENTICATION_INFO_STRING);
} catch (Ex\EnvironmentIsBrokenException $ex) {
// Do this, otherwise it will stay in the "tests are running" state.
$test_state = 3;
@ -97,9 +93,7 @@ class RuntimeTests extends Crypto
// the user into thinking it's just an invalid ciphertext!
throw new Ex\EnvironmentIsBrokenException();
}
if ($decrypted !== $data) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($decrypted === $data);
// Modifying the ciphertext: Appending a string.
try {
@ -167,9 +161,7 @@ class RuntimeTests extends Crypto
'34007208d5b887185865'
);
$computed_okm = Core::HKDF('sha256', $ikm, $length, $info, $salt);
if ($computed_okm !== $okm) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($computed_okm === $okm);
// Test Case 7
$ikm = \str_repeat("\x0c", 22);
@ -180,9 +172,7 @@ class RuntimeTests extends Crypto
'673a081d70cce7acfc48'
);
$computed_okm = Core::HKDF('sha1', $ikm, $length, '', null);
if ($computed_okm !== $okm) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($computed_okm === $okm);
}
/**
@ -197,9 +187,9 @@ class RuntimeTests extends Crypto
$key = \str_repeat("\x0b", 20);
$data = 'Hi There';
$correct = 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7';
if (\hash_hmac(Core::HASH_FUNCTION_NAME, $data, $key) !== $correct) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue(
\hash_hmac(Core::HASH_FUNCTION_NAME, $data, $key) === $correct
);
}
/**
@ -230,18 +220,9 @@ class RuntimeTests extends Crypto
);
$computed_ciphertext = Crypto::plainEncrypt($plaintext, $key, $iv);
if ($computed_ciphertext !== $ciphertext) {
echo \str_repeat("\n", 30);
echo \bin2hex($computed_ciphertext);
echo "\n---\n";
echo \bin2hex($ciphertext);
echo \str_repeat("\n", 30);
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($computed_ciphertext === $ciphertext);
$computed_plaintext = Crypto::plainDecrypt($ciphertext, $key, $iv, Core::CIPHER_METHOD);
if ($computed_plaintext !== $plaintext) {
throw new Ex\EnvironmentIsBrokenException();
}
Core::ensureTrue($computed_plaintext === $plaintext);
}
}

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -10,6 +10,7 @@ namespace Joomla\Application;
use Joomla\Event\DispatcherAwareInterface;
use Joomla\Event\DispatcherAwareTrait;
use Joomla\Event\EventInterface;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Psr\Log\LoggerAwareInterface;
@ -84,13 +85,14 @@ abstract class AbstractApplication implements LoggerAwareInterface, DispatcherAw
/**
* Dispatches an application event if the dispatcher has been set.
*
* @param string $eventName The event to dispatch.
* @param string $eventName The event to dispatch.
* @param Event|null $event The event object.
*
* @return void
* @return EventInterface|void The dispatched event or null if no dispatcher is set
*
* @since __DEPLOY_VERSION__
*/
protected function dispatchEvent(string $eventName)
protected function dispatchEvent(string $eventName, EventInterface $event = null)
{
try
{
@ -101,7 +103,7 @@ abstract class AbstractApplication implements LoggerAwareInterface, DispatcherAw
return;
}
$dispatcher->dispatch($eventName, new Event\ApplicationEvent($eventName, $this));
return $dispatcher->dispatch($eventName, $event ?: new Event\ApplicationEvent($eventName, $this));
}
/**
@ -124,12 +126,19 @@ abstract class AbstractApplication implements LoggerAwareInterface, DispatcherAw
*/
public function execute()
{
$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);
try
{
$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);
// Perform application routines.
$this->doExecute();
// Perform application routines.
$this->doExecute();
$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
}
catch (\Throwable $throwable)
{
$this->dispatchEvent(ApplicationEvents::ERROR, new Event\ApplicationErrorEvent($thrown, $this));
}
}
/**

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -44,7 +44,7 @@ abstract class AbstractWebApplication extends AbstractApplication
* HTTP protocol version.
*
* @var string
* @since 1.0
* @since 1.9.0
*/
public $httpVersion = '1.1';
@ -209,17 +209,24 @@ abstract class AbstractWebApplication extends AbstractApplication
*/
public function execute()
{
$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);
// Perform application routines.
$this->doExecute();
$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
// If gzip compression is enabled in configuration and the server is compliant, compress the output.
if ($this->get('gzip') && !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'))
try
{
$this->compress();
$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);
// Perform application routines.
$this->doExecute();
$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
// If gzip compression is enabled in configuration and the server is compliant, compress the output.
if ($this->get('gzip') && !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'))
{
$this->compress();
}
}
catch (\Throwable $throwable)
{
$this->dispatchEvent(ApplicationEvents::ERROR, new Event\ApplicationErrorEvent($throwable, $this));
}
$this->dispatchEvent(ApplicationEvents::BEFORE_RESPOND);
@ -414,14 +421,14 @@ abstract class AbstractWebApplication extends AbstractApplication
// If the headers have already been sent we need to send the redirect statement via JavaScript.
if ($this->checkHeadersSent())
{
echo "<script>document.location.href='$url';</script>\n";
echo "<script>document.location.href=" . json_encode($url) . ";</script>\n";
}
// We have to use a JavaScript redirect here because MSIE doesn't play nice with UTF-8 URLs.
elseif (($this->client->engine == Web\WebClient::TRIDENT) && !static::isAscii($url))
{
$html = '<html><head>';
$html .= '<meta http-equiv="content-type" content="text/html; charset=' . $this->charSet . '" />';
$html .= '<script>document.location.href=\'' . $url . '\';</script>';
$html .= '<script>document.location.href=' . json_encode($url) . ';</script>';
$html .= '</head><body></body></html>';
echo $html;
@ -876,7 +883,14 @@ abstract class AbstractWebApplication extends AbstractApplication
{
$serverSSLVar = $this->input->server->getString('HTTPS', '');
return (!empty($serverSSLVar) && strtolower($serverSSLVar) != 'off');
if (!empty($serverSSLVar) && strtolower($serverSSLVar) !== 'off')
{
return true;
}
$serverForwarderProtoVar = $this->input->server->getString('HTTP_X_FORWARDED_PROTO', '');
return !empty($serverForwarderProtoVar) && strtolower($serverForwarderProtoVar) === 'https';
}
/**

View File

@ -15,6 +15,16 @@ namespace Joomla\Application;
*/
final class ApplicationEvents
{
/**
* The ERROR event is an event triggered when a Throwable is uncaught.
*
* This event allows you to inspect the Throwable and implement additional error handling/reporting mechanisms.
*
* @var string
* @since __DEPLOY_VERSION__
*/
const ERROR = 'application.error';
/**
* The BEFORE_EXECUTE event is an event triggered before the application is executed.
*

View File

@ -0,0 +1,60 @@
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Controller;
use Psr\Container\ContainerInterface;
/**
* Controller resolver which supports creating controllers from a PSR-11 compatible container
*
* Controllers must be registered in the container using their FQCN as a service key
*
* @since __DEPLOY_VERSION__
*/
class ContainerControllerResolver extends ControllerResolver
{
/**
* The container to search for controllers in
*
* @var ContainerInterface
* @since __DEPLOY_VERSION__
*/
private $container;
/**
* Constructor
*
* @param ContainerInterface $container The container to search for controllers in
*
* @since __DEPLOY_VERSION__
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Instantiate a controller class
*
* @param string $class The class to instantiate
*
* @return object Controller class instance
*
* @since __DEPLOY_VERSION__
*/
protected function instantiateController(string $class)
{
if ($this->container->has($class))
{
return $this->container->get($class);
}
return parent::instantiateController($class);
}
}

View File

@ -0,0 +1,129 @@
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Controller;
use Joomla\Controller\ControllerInterface;
use Joomla\Router\ResolvedRoute;
/**
* Resolves a controller for the given route.
*
* @since __DEPLOY_VERSION__
*/
class ControllerResolver implements ControllerResolverInterface
{
/**
* Resolve the controller for a route
*
* @param ResolvedRoute $route The route to resolve the controller for
*
* @return callable
*
* @since __DEPLOY_VERSION__
* @throws \InvalidArgumentException
*/
public function resolve(ResolvedRoute $route): callable
{
$controller = $route->getController();
// Try to resolve a callable defined as an array
if (is_array($controller))
{
if (isset($controller[0]) && is_string($controller[0]) && isset($controller[1]))
{
if (!class_exists($controller[0]))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
try
{
$controller[0] = $this->instantiateController($controller[0]);
}
catch (\ArgumentCountError $error)
{
// On PHP 7.1, we can catch missing argument errors to provide a more useful error message
throw new \InvalidArgumentException(
sprintf(
'Controller `%s` has required constructor arguments, cannot instantiate the class', $controller[0]
),
0,
$error
);
}
}
if (!is_callable($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
return $controller;
}
// Try to resolve an invokable object
if (is_object($controller))
{
if (!is_callable($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
return $controller;
}
// Try to resolve a known function
if (function_exists($controller))
{
return $controller;
}
// Try to resolve a class name if it implements our ControllerInterface
if (is_string($controller) && interface_exists(ControllerInterface::class))
{
if (!class_exists($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
try
{
return [$this->instantiateController($controller), 'execute'];
}
catch (\ArgumentCountError $error)
{
// On PHP 7.1, we can catch missing argument errors to provide a more useful error message
throw new \InvalidArgumentException(
sprintf(
'Controller `%s` has required constructor arguments, cannot instantiate the class', $controller
),
0,
$error
);
}
}
// Unsupported resolution
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
/**
* Instantiate a controller class
*
* @param string $class The class to instantiate
*
* @return object Controller class instance
*
* @since __DEPLOY_VERSION__
*/
protected function instantiateController(string $class)
{
return new $class;
}
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Controller;
use Joomla\Router\ResolvedRoute;
/**
* Interface defining a controller resolver.
*
* @since __DEPLOY_VERSION__
*/
interface ControllerResolverInterface
{
/**
* Resolve the controller for a route
*
* @param ResolvedRoute $route The route to resolve the controller for
*
* @return callable
*
* @since __DEPLOY_VERSION__
* @throws \InvalidArgumentException
*/
public function resolve(ResolvedRoute $route): callable;
}

View File

@ -0,0 +1,70 @@
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Event;
use Joomla\Application\AbstractApplication;
use Joomla\Application\ApplicationEvents;
use Joomla\Event\Event;
/**
* Event class thrown when an application error occurs.
*
* @since __DEPLOY_VERSION__
*/
class ApplicationErrorEvent extends ApplicationEvent
{
/**
* The Throwable object with the error data.
*
* @var \Throwable
* @since __DEPLOY_VERSION__
*/
private $error;
/**
* Event constructor.
*
* @param \Throwable $error The Throwable object with the error data.
* @param AbstractApplication $application The active application.
*
* @since __DEPLOY_VERSION__
*/
public function __construct(\Throwable $error, AbstractApplication $application)
{
parent::__construct(ApplicationEvents::ERROR, $application);
$this->error = $error;
}
/**
* Get the error object.
*
* @return \Throwable
*
* @since __DEPLOY_VERSION__
*/
public function getError(): \Throwable
{
return $this->error;
}
/**
* Set the error object.
*
* @param \Throwable $error The error object to set to the event.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function setError(\Throwable $error)
{
$this->error = $error;
}
}

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -452,16 +452,29 @@ class WebClient
}
elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false)
{
$result = explode('/', stristr($userAgent, 'Opera'));
$version = explode(' ', $result[1]);
$version = false;
if ($version[0] >= 15)
if (preg_match('/Opera[\/| ]?([0-9.]+)/u', $userAgent, $match))
{
$version = floatval($match[1]);
}
if (preg_match('/Version\/([0-9.]+)/u', $userAgent, $match))
{
if (floatval($match[1]) >= 10)
{
$version = floatval($match[1]);
}
}
if ($version !== false && $version >= 15)
{
$this->engine = self::BLINK;
}
// Sometimes Opera browsers don't say Presto.
$this->engine = self::PRESTO;
else
{
$this->engine = self::PRESTO;
}
}
elseif (stripos($userAgent, 'KHTML') !== false)
{

View File

@ -0,0 +1,99 @@
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application;
use Joomla\Application\Controller\ControllerResolverInterface;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Joomla\Router\Router;
use Psr\Http\Message\ResponseInterface;
/**
* A basic web application class for handing HTTP requests.
*
* @since __DEPLOY_VERSION__
*/
class WebApplication extends AbstractWebApplication
{
/**
* The application's controller resolver.
*
* @var ControllerResolverInterface
* @since __DEPLOY_VERSION__
*/
protected $controllerResolver;
/**
* The application's router.
*
* @var Router
* @since __DEPLOY_VERSION__
*/
protected $router;
/**
* Class constructor.
*
* @param ControllerResolverInterface $controllerResolver The application's controller resolver
* @param Router $router The application's router
* @param Input $input An optional argument to provide dependency injection for the application's
* input object. If the argument is an Input object that object will become
* the application's input object, otherwise a default input object is
* created.
* @param Registry $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a Registry object that object will
* become the application's config object, otherwise a default config object
* is created.
* @param Web\WebClient $client An optional argument to provide dependency injection for the application's
* client object. If the argument is a Web\WebClient object that object will
* become the application's client object, otherwise a default client object
* is created.
* @param ResponseInterface $response An optional argument to provide dependency injection for the application's
* response object. If the argument is a ResponseInterface object that object
* will become the application's response object, otherwise a default response
* object is created.
*
* @since __DEPLOY_VERSION__
*/
public function __construct(
ControllerResolverInterface $controllerResolver,
Router $router,
Input $input = null,
Registry $config = null,
Web\WebClient $client = null,
ResponseInterface $response = null
)
{
$this->controllerResolver = $controllerResolver;
$this->router = $router;
// Call the constructor as late as possible (it runs `initialise`).
parent::__construct($input, $config, $client, $response);
}
/**
* Method to run the application routines.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function doExecute()
{
$route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod());
// Add variables to the input if not already set
foreach ($route->getRouteVariables() as $key => $value)
{
$this->input->def($key, $value);
}
call_user_func($this->controllerResolver->resolve($route));
}
}

View File

@ -106,9 +106,10 @@ class DatabaseStrategy extends AbstractUsernamePasswordAuthenticationStrategy
{
$password = $this->db->setQuery(
$this->db->getQuery(true)
->select($this->dbOptions['password_column'])
->from($this->dbOptions['database_table'])
->where($this->dbOptions['username_column'] . ' = ' . $this->db->quote($username))
->select($this->db->quoteName($this->dbOptions['password_column']))
->from($this->db->quoteName($this->dbOptions['database_table']))
->where($this->db->quoteName($this->dbOptions['username_column']) . ' = ?')
->bind(1, $username)
)->loadResult();
}
catch (\RuntimeException $exception)

View File

@ -344,9 +344,8 @@ class Application extends AbstractApplication
return;
}
$event = new Event\BeforeCommandExecuteEvent($this, $command);
$dispatcher->dispatch(ConsoleEvents::BEFORE_COMMAND_EXECUTE, $event);
/** @var Event\BeforeCommandExecuteEvent $event */
$event = $this->dispatchEvent(ConsoleEvents::BEFORE_COMMAND_EXECUTE, new Event\BeforeCommandExecuteEvent($this, $command));
if ($event->isCommandEnabled())
{
@ -413,8 +412,8 @@ class Application extends AbstractApplication
if ($dispatcher)
{
$event = new Event\ConsoleErrorEvent($thrown, $this, $this->activeCommand);
$dispatcher->dispatch(ConsoleEvents::ERROR, $event);
/** @var Event\ConsoleErrorEvent $event */
$event = $this->dispatchEvent(ApplicationEvents::ERROR, new Event\ConsoleErrorEvent($thrown, $this, $this->activeCommand));
$thrown = $event->getError();
@ -451,8 +450,8 @@ class Application extends AbstractApplication
{
if ($dispatcher)
{
$event = new Event\TerminateEvent($this->exitCode, $this, $this->activeCommand);
$dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
/** @var Event\TerminateEvent $event */
$event = $this->dispatchEvent(ConsoleEvents::TERMINATE, new Event\TerminateEvent($this->exitCode, $this, $this->activeCommand));
$this->exitCode = $event->getExitCode();
}

View File

@ -26,17 +26,6 @@ final class ConsoleEvents
*/
const BEFORE_COMMAND_EXECUTE = 'console.before_command_execute';
/**
* The ERROR event is an event triggered when a Throwable is uncaught.
*
* This event allows you to inspect the Throwable, implement additional error handling/reporting
* mechanisms, and set the process' exit code.
*
* @var string
* @since __DEPLOY_VERSION__
*/
const ERROR = 'console.error';
/**
* The TERMINATE event is an event triggered immediately before the application is exited.
*

View File

@ -8,9 +8,9 @@
namespace Joomla\Console\Event;
use Joomla\Application\ApplicationEvents;
use Joomla\Console\Application;
use Joomla\Console\CommandInterface;
use Joomla\Console\ConsoleEvents;
/**
* Event triggered when an uncaught Throwable is received by the application.
@ -46,7 +46,7 @@ class ConsoleErrorEvent extends ConsoleEvent
*/
public function __construct(\Throwable $error, Application $application, CommandInterface $command = null)
{
parent::__construct(ConsoleEvents::ERROR, $application, $command);
parent::__construct(ApplicationEvents::ERROR, $application, $command);
$this->error = $error;
}

View File

@ -199,6 +199,14 @@ abstract class DatabaseQuery implements QueryInterface
*/
protected $selectRowNumber = null;
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = [];
/**
* Class constructor.
*
@ -1196,6 +1204,35 @@ abstract class DatabaseQuery implements QueryInterface
return $result;
}
/**
* Generate a SQL statement to check if column represents a zero or null datetime.
*
* Usage:
* $query->where($query->isNullDatetime('modified_date'));
*
* @param string $column A column name.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function isNullDatetime($column)
{
if (!$this->db instanceof DatabaseInterface)
{
throw new \RuntimeException(sprintf('A %s instance is not set to the query object.', DatabaseInterface::class));
}
if ($this->nullDatetimeList)
{
return "($column IN ("
. implode(', ', $this->db->quote($this->nullDatetimeList))
. ") OR $column IS NULL)";
}
return "$column IS NULL";
}
/**
* Add a ordering column to the ORDER clause of the query.
*
@ -1548,6 +1585,26 @@ abstract class DatabaseQuery implements QueryInterface
return $this;
}
/**
* Add a WHERE IN statement to the query
*
* Usage
* $query->whereIn('id', [1, 2, 3]);
*
* @param string $keyName key name for the where clause
* @param array $keyValues array of values to be matched
*
* @return $this
*
* @since __DEPLOY_VERSION__
*/
public function whereIn($keyName, $keyValues)
{
return $this->where(
$keyName . ' IN (' . implode(', ', $keyValues) . ')'
);
}
/**
* Extend the WHERE clause with a single condition or an array of conditions, with a potentially
* different logical operator from the one in the current WHERE clause.

View File

@ -20,6 +20,14 @@ class MysqlQuery extends PdoQuery
{
use MysqlQueryBuilder;
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = ['0000-00-00 00:00:00', '1000-01-01 00:00:00'];
/**
* Magic function to convert the query to a string.
*

View File

@ -60,6 +60,14 @@ class MysqliQuery extends DatabaseQuery implements LimitableInterface
ParameterType::STRING => 's',
];
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = ['0000-00-00 00:00:00', '1000-01-01 00:00:00'];
/**
* Magic function to convert the query to a string.
*

View File

@ -57,6 +57,14 @@ abstract class PdoQuery extends DatabaseQuery implements LimitableInterface
ParameterType::STRING => \PDO::PARAM_STR,
];
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = ['0000-00-00 00:00:00'];
/**
* Method to add a variable to an internal array that will be bound to a prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded array when the passed in value is null.

View File

@ -20,6 +20,14 @@ class PgsqlQuery extends PdoQuery
{
use PostgresqlQueryBuilder;
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = ['1970-01-01 00:00:00'];
/**
* Magic function to convert the query to a string, only for PostgreSQL specific queries
*

View File

@ -377,6 +377,20 @@ interface QueryInterface extends PreparableInterface
*/
public function nullDate($quoted = true);
/**
* Generate a SQL statement to check if column represents a zero or null datetime.
*
* Usage:
* $query->where($query->isNullDatetime('modified_date'));
*
* @param string $column A column name.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function isNullDatetime($column);
/**
* Add an ordering column to the ORDER clause of the query.
*
@ -519,6 +533,21 @@ interface QueryInterface extends PreparableInterface
*/
public function where($conditions, $glue = 'AND');
/**
* Add a WHERE IN statement to the query
*
* Usage:
* $query->whereIn('id', [1, 2, 3]);
*
* @param string $keyName A string representing the key name for the where clause
* @param array $keyValues The array of values to be matched
*
* @return $this
*
* @since __DEPLOY_VERSION__
*/
public function whereIn($keyName, $keyValues);
/**
* Extend the WHERE clause with a single condition or an array of conditions, with a potentially different logical operator from the one in the
* current WHERE clause.

View File

@ -64,6 +64,14 @@ class SqlsrvQuery extends DatabaseQuery implements LimitableInterface
*/
protected $limit;
/**
* The list of zero or null representation of a datetime.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $nullDatetimeList = ['1900-01-01 00:00:00'];
/**
* Magic function to convert the query to a string.
*

View File

@ -51,6 +51,20 @@ final class DelegatingDispatcher implements DispatcherInterface
return $this->dispatcher->addListener($eventName, $callback, $priority);
}
/**
* Adds an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function addSubscriber(SubscriberInterface $subscriber)
{
$this->dispatcher->addSubscriber($subscriber);
}
/**
* Dispatches an event to all registered listeners.
*
@ -66,6 +80,37 @@ final class DelegatingDispatcher implements DispatcherInterface
return $this->dispatcher->dispatch($name, $event);
}
/**
* Get the listeners registered to the given event.
*
* @param string $event The event to fetch listeners for
*
* @return callable[] An array of registered listeners sorted according to their priorities.
*
* @since __DEPLOY_VERSION__
*/
public function getListeners($event)
{
return $this->dispatcher->getListeners($event);
}
/**
* Tell if the given listener has been added.
*
* If an event is specified, it will tell if the listener is registered for that event.
*
* @param callable $callback The callable to check is listening to the event.
* @param string $eventName The event to check a listener is subscribed to.
*
* @return boolean True if the listener is registered, false otherwise.
*
* @since __DEPLOY_VERSION__
*/
public function hasListener(callable $callback, $eventName = null)
{
return $this->dispatcher->hasListener($callback, $eventName);
}
/**
* Removes an event listener from the specified event.
*
@ -81,6 +126,20 @@ final class DelegatingDispatcher implements DispatcherInterface
$this->dispatcher->removeListener($eventName, $listener);
}
/**
* Removes an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function removeSubscriber(SubscriberInterface $subscriber)
{
$this->dispatcher->removeSubscriber($subscriber);
}
/**
* Trigger an event.
*

View File

@ -13,7 +13,7 @@ namespace Joomla\Event;
*
* @since 1.0
*/
class Dispatcher implements DispatcherInterface, SubscriberManagerInterface
class Dispatcher implements DispatcherInterface
{
/**
* An array of registered events indexed by the event names.
@ -216,7 +216,7 @@ class Dispatcher implements DispatcherInterface, SubscriberManagerInterface
*
* @param string $event The event to fetch listeners for
*
* @return object[] An array of registered listeners sorted according to their priorities.
* @return callable[] An array of registered listeners sorted according to their priorities.
*
* @since 1.0
*/

View File

@ -15,19 +15,6 @@ namespace Joomla\Event;
*/
interface DispatcherInterface
{
/**
* Attaches a listener to an event
*
* @param string $eventName The event to listen to.
* @param callable $callback A callable function.
* @param integer $priority The priority at which the $callback executed.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function addListener(string $eventName, callable $callback, int $priority = 0): bool;
/**
* Dispatches an event to all registered listeners.
*
@ -42,6 +29,44 @@ interface DispatcherInterface
*/
public function dispatch(string $name, EventInterface $event = null): EventInterface;
/**
* Attaches a listener to an event
*
* @param string $eventName The event to listen to.
* @param callable $callback A callable function.
* @param integer $priority The priority at which the $callback executed.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function addListener(string $eventName, callable $callback, int $priority = 0): bool;
/**
* Get the listeners registered to the given event.
*
* @param string $event The event to fetch listeners for
*
* @return callable[] An array of registered listeners sorted according to their priorities.
*
* @since __DEPLOY_VERSION__
*/
public function getListeners($event);
/**
* Tell if the given listener has been added.
*
* If an event is specified, it will tell if the listener is registered for that event.
*
* @param callable $callback The callable to check is listening to the event.
* @param string $eventName The event to check a listener is subscribed to.
*
* @return boolean True if the listener is registered, false otherwise.
*
* @since __DEPLOY_VERSION__
*/
public function hasListener(callable $callback, $eventName = null);
/**
* Removes an event listener from the specified event.
*
@ -53,4 +78,26 @@ interface DispatcherInterface
* @since __DEPLOY_VERSION__
*/
public function removeListener(string $eventName, callable $listener);
/**
* Adds an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function addSubscriber(SubscriberInterface $subscriber);
/**
* Removes an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function removeSubscriber(SubscriberInterface $subscriber);
}

View File

@ -110,7 +110,7 @@ class ListenersPriorityQueue implements \IteratorAggregate, \Countable
/**
* Get all listeners contained in this queue, sorted according to their priority.
*
* @return object[] An array of listeners.
* @return callable[] An array of listeners.
*
* @since 1.0
*/

View File

@ -1,39 +0,0 @@
<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* Interface for event dispatchers which manage event subscribers.
*
* @since __DEPLOY_VERSION__
*/
interface SubscriberManagerInterface
{
/**
* Adds an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function addSubscriber(SubscriberInterface $subscriber);
/**
* Removes an event subscriber.
*
* @param SubscriberInterface $subscriber The subscriber.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function removeSubscriber(SubscriberInterface $subscriber);
}

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Filter Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -113,6 +113,7 @@ class InputFilter
'bgsound',
'base',
'basefont',
'canvas',
'embed',
'frame',
'frameset',
@ -172,7 +173,8 @@ class InputFilter
* @since 1.0
*/
public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = self::TAGS_WHITELIST, $attrMethod = self::ATTR_WHITELIST,
$xssAuto = 1)
$xssAuto = 1
)
{
// Make sure user defined arrays are in lowercase
$tagsArray = array_map('strtolower', (array) $tagsArray);
@ -598,49 +600,49 @@ class InputFilter
$attr = '';
// Is there a tag? If so it will certainly start with a '<'.
$tagOpen_start = StringHelper::strpos($source, '<');
$tagOpenStart = StringHelper::strpos($source, '<');
while ($tagOpen_start !== false)
while ($tagOpenStart !== false)
{
// Get some information about the tag we are processing
$preTag .= StringHelper::substr($postTag, 0, $tagOpen_start);
$postTag = StringHelper::substr($postTag, $tagOpen_start);
$preTag .= StringHelper::substr($postTag, 0, $tagOpenStart);
$postTag = StringHelper::substr($postTag, $tagOpenStart);
$fromTagOpen = StringHelper::substr($postTag, 1);
$tagOpen_end = StringHelper::strpos($fromTagOpen, '>');
$tagOpenEnd = StringHelper::strpos($fromTagOpen, '>');
// Check for mal-formed tag where we have a second '<' before the first '>'
$nextOpenTag = (StringHelper::strlen($postTag) > $tagOpen_start) ? StringHelper::strpos($postTag, '<', $tagOpen_start + 1) : false;
$nextOpenTag = (StringHelper::strlen($postTag) > $tagOpenStart) ? StringHelper::strpos($postTag, '<', $tagOpenStart + 1) : false;
if (($nextOpenTag !== false) && ($nextOpenTag < $tagOpen_end))
if (($nextOpenTag !== false) && ($nextOpenTag < $tagOpenEnd))
{
// At this point we have a mal-formed tag -- remove the offending open
$postTag = StringHelper::substr($postTag, 0, $tagOpen_start) . StringHelper::substr($postTag, $tagOpen_start + 1);
$tagOpen_start = StringHelper::strpos($postTag, '<');
$postTag = StringHelper::substr($postTag, 0, $tagOpenStart) . StringHelper::substr($postTag, $tagOpenStart + 1);
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Let's catch any non-terminated tags and skip over them
if ($tagOpen_end === false)
if ($tagOpenEnd === false)
{
$postTag = StringHelper::substr($postTag, $tagOpen_start + 1);
$tagOpen_start = StringHelper::strpos($postTag, '<');
$postTag = StringHelper::substr($postTag, $tagOpenStart + 1);
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Do we have a nested tag?
$tagOpen_nested = StringHelper::strpos($fromTagOpen, '<');
$tagOpenNested = StringHelper::strpos($fromTagOpen, '<');
if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end))
if (($tagOpenNested !== false) && ($tagOpenNested < $tagOpenEnd))
{
$preTag .= StringHelper::substr($postTag, 0, ($tagOpen_nested + 1));
$postTag = StringHelper::substr($postTag, ($tagOpen_nested + 1));
$tagOpen_start = StringHelper::strpos($postTag, '<');
$preTag .= StringHelper::substr($postTag, 0, ($tagOpenNested + 1));
$postTag = StringHelper::substr($postTag, ($tagOpenNested + 1));
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Let's get some information about our tag and setup attribute pairs
$tagOpen_nested = (StringHelper::strpos($fromTagOpen, '<') + $tagOpen_start + 1);
$currentTag = StringHelper::substr($fromTagOpen, 0, $tagOpen_end);
$tagOpenNested = (StringHelper::strpos($fromTagOpen, '<') + $tagOpenStart + 1);
$currentTag = StringHelper::substr($fromTagOpen, 0, $tagOpenEnd);
$tagLength = StringHelper::strlen($currentTag);
$tagLeft = $currentTag;
$attrSet = array();
@ -671,7 +673,7 @@ class InputFilter
|| ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto)))
{
$postTag = StringHelper::substr($postTag, ($tagLength + 2));
$tagOpen_start = StringHelper::strpos($postTag, '<');
$tagOpenStart = StringHelper::strpos($postTag, '<');
// Strip tag
continue;
@ -804,7 +806,7 @@ class InputFilter
// Find next tag's start and continue iteration
$postTag = StringHelper::substr($postTag, ($tagLength + 2));
$tagOpen_start = StringHelper::strpos($postTag, '<');
$tagOpenStart = StringHelper::strpos($postTag, '<');
}
// Append any code after the end of tags and return
@ -844,8 +846,8 @@ class InputFilter
$attrSubSet = explode('=', trim($attrSet[$i]), 2);
// Take the last attribute in case there is an attribute with no value
$attrSubSet_0 = explode(' ', trim($attrSubSet[0]));
$attrSubSet[0] = array_pop($attrSubSet_0);
$attrSubSet0 = explode(' ', trim($attrSubSet[0]));
$attrSubSet[0] = array_pop($attrSubSet0);
$attrSubSet[0] = strtolower($attrSubSet[0]);
$quoteStyle = version_compare(PHP_VERSION, '5.4', '>=') ? ENT_QUOTES | ENT_HTML401 : ENT_QUOTES;
@ -855,12 +857,15 @@ class InputFilter
$attrSubSet[0] = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $attrSubSet[0]);
$attrSubSet[0] = preg_replace('/\s+/u', '', $attrSubSet[0]);
// Replace special blacklisted chars here
// Remove blacklisted chars from the attribute name
foreach ($this->blacklistedChars as $blacklistedChar)
{
$attrSubSet[0] = str_replace($blacklistedChar, '', $attrSubSet[0]);
$attrSubSet[0] = str_ireplace($blacklistedChar, '', $attrSubSet[0]);
}
// Remove all symbols
$attrSubSet[0] = preg_replace('/[^\p{L}\p{N}\-\s]/u', '', $attrSubSet[0]);
// Remove all "non-regular" attribute names
// AND blacklisted attributes
if ((!preg_match('/[a-z]*$/i', $attrSubSet[0]))
@ -876,6 +881,12 @@ class InputFilter
continue;
}
// Remove blacklisted chars from the attribute value
foreach ($this->blacklistedChars as $blacklistedChar)
{
$attrSubSet[1] = str_ireplace($blacklistedChar, '', $attrSubSet[1]);
}
// Trim leading and trailing spaces
$attrSubSet[1] = trim($attrSubSet[1]);

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Filter Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -24,15 +24,15 @@ class OutputFilter
* Object parameters that are non-string, array, object or start with underscore
* will be converted
*
* @param object &$mixed An object to be parsed
* @param integer $quote_style The optional quote style for the htmlspecialchars function
* @param mixed $exclude_keys An optional string single field name or array of field names not to be parsed (eg, for a textarea)
* @param object $mixed An object to be parsed
* @param integer $quoteStyle The optional quote style for the htmlspecialchars function
* @param mixed $excludeKeys An optional string single field name or array of field names not to be parsed (eg, for a textarea)
*
* @return void
*
* @since 1.0
*/
public static function objectHtmlSafe(&$mixed, $quote_style = ENT_QUOTES, $exclude_keys = '')
public static function objectHtmlSafe(&$mixed, $quoteStyle = ENT_QUOTES, $excludeKeys = '')
{
if (is_object($mixed))
{
@ -43,16 +43,16 @@ class OutputFilter
continue;
}
if (is_string($exclude_keys) && $k == $exclude_keys)
if (is_string($excludeKeys) && $k == $excludeKeys)
{
continue;
}
elseif (is_array($exclude_keys) && in_array($k, $exclude_keys))
elseif (is_array($excludeKeys) && in_array($k, $excludeKeys))
{
continue;
}
$mixed->$k = htmlspecialchars($v, $quote_style, 'UTF-8');
$mixed->$k = htmlspecialchars($v, $quoteStyle, 'UTF-8');
}
}
}
@ -72,7 +72,7 @@ class OutputFilter
return preg_replace_callback(
"#$regex#i",
function($m)
function ($m)
{
return preg_replace('#&(?!amp;)#', '&amp;', $m[0]);
},
@ -163,7 +163,7 @@ class OutputFilter
/**
* Cleans text of all formatting and scripting code
*
* @param string &$text Text to clean
* @param string $text Text to clean
*
* @return string Cleaned text.
*

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class fill background with color;
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Backgroundfill extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the brightness of an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Brightness extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the contrast of an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Contrast extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class to add an edge detect effect to an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Edgedetect extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class to emboss an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Emboss extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class to transform an image to grayscale.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Grayscale extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class to negate the colors of an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Negate extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class to make an image appear "sketchy".
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Sketchy extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -13,7 +13,8 @@ use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the smoothness of an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Smooth extends ImageFilter
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -16,7 +16,8 @@ use Psr\Log\LoggerAwareInterface;
/**
* Class to manipulate an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Image implements LoggerAwareInterface
{

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -16,7 +16,8 @@ use Psr\Log\LoggerAwareInterface;
/**
* Class to manipulate an image.
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
abstract class ImageFilter implements LoggerAwareInterface
{

View File

@ -42,7 +42,7 @@ class Cli extends Input
*
* @since 1.0
*/
public function __construct(array $source = array(), array $options = array())
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{

View File

@ -25,7 +25,7 @@ class Cookie extends Input
*
* @since 1.0
*/
public function __construct(array $source = array(), array $options = array())
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{

View File

@ -34,7 +34,7 @@ class Files extends Input
*
* @since 1.0
*/
public function __construct(array $source = array(), array $options = array())
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{

View File

@ -88,7 +88,7 @@ class Input implements \Serializable, \Countable
*
* @since 1.0
*/
public function __construct($source = array(), array $options = array())
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
@ -132,7 +132,7 @@ class Input implements \Serializable, \Countable
if (class_exists($className))
{
$this->inputs[$name] = new $className(array(), $this->options);
$this->inputs[$name] = new $className(null, $this->options);
return $this->inputs[$name];
}

View File

@ -34,7 +34,7 @@ class Json extends Input
*
* @since 1.0
*/
public function __construct(array $source = array(), array $options = array())
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
@ -45,7 +45,7 @@ class Json extends Input
$this->filter = new Filter\InputFilter;
}
if (is_null($source) || empty($source))
if (is_null($source))
{
$this->raw = file_get_contents('php://input');

View File

@ -2,7 +2,7 @@
/**
* Part of the Joomla Framework LDAP Package
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
@ -11,7 +11,8 @@ namespace Joomla\Ldap;
/**
* LDAP client class
*
* @since 1.0
* @since 1.0
* @deprecated The joomla/ldap package is deprecated
*/
class LdapClient
{

View File

@ -51,13 +51,19 @@ class Json implements FormatInterface
*/
public function stringToObject($data, array $options = ['processSections' => false])
{
$data = trim($data);
// Because developers are clearly not validating their data before pushing it into a Registry, we'll do it for them
if (empty($data))
{
return new \stdClass;
}
$decoded = json_decode($data);
// Check for an error decoding the data
if ($decoded === null)
if ($decoded === null && json_last_error() !== JSON_ERROR_NONE)
{
$data = trim($data);
// If it's an ini file, parse as ini.
if ($data !== '' && $data[0] !== '{')
{

View File

@ -643,6 +643,24 @@ class Session implements SessionInterface, DispatcherAwareInterface
return $this->store->gc();
}
/**
* Aborts the current session
*
* @return boolean
*
* @see session_abort()
* @since __DEPLOY_VERSION__
*/
public function abort()
{
if (!$this->isActive())
{
return true;
}
return $this->store->abort();
}
/**
* Create a token-string
*

View File

@ -251,4 +251,14 @@ interface SessionInterface extends \IteratorAggregate
* @since __DEPLOY_VERSION__
*/
public function gc();
/**
* Aborts the current session
*
* @return boolean
*
* @see session_abort()
* @since __DEPLOY_VERSION__
*/
public function abort();
}

View File

@ -140,6 +140,24 @@ class NativeStorage implements StorageInterface
return session_gc();
}
/**
* Aborts the current session
*
* @return boolean
*
* @see session_abort()
* @since __DEPLOY_VERSION__
*/
public function abort()
{
if (!$this->isStarted())
{
return true;
}
return session_abort();
}
/**
* Get data from the session store
*

View File

@ -113,6 +113,22 @@ class RuntimeStorage implements StorageInterface
return 0;
}
/**
* Aborts the current session
*
* @return boolean
*
* @see session_abort()
* @since __DEPLOY_VERSION__
*/
public function abort()
{
$this->closed = true;
$this->started = false;
return true;
}
/**
* Generates a session ID
*

View File

@ -180,4 +180,14 @@ interface StorageInterface
* @since __DEPLOY_VERSION__
*/
public function gc();
/**
* Aborts the current session
*
* @return boolean
*
* @see session_abort()
* @since __DEPLOY_VERSION__
*/
public function abort();
}

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -3,12 +3,12 @@
* Random_* Compatibility Library
* for using the new PHP 7 random_* API in PHP 5 projects
*
* @version 2.0.10
* @released 2017-03-13
* @version 2.0.15
* @released 2018-06-08
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -54,9 +54,9 @@ if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
$RandomCompatDIR = dirname(__FILE__);
require_once $RandomCompatDIR . '/byte_safe_strings.php';
require_once $RandomCompatDIR . '/cast_to_int.php';
require_once $RandomCompatDIR . '/error_polyfill.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'byte_safe_strings.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'cast_to_int.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'error_polyfill.php';
if (!is_callable('random_bytes')) {
/**
@ -76,9 +76,9 @@ if (!is_callable('random_bytes')) {
if (extension_loaded('libsodium')) {
// See random_bytes_libsodium.php
if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) {
require_once $RandomCompatDIR . '/random_bytes_libsodium.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium.php';
} elseif (method_exists('Sodium', 'randombytes_buf')) {
require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium_legacy.php';
}
}
@ -117,7 +117,7 @@ if (!is_callable('random_bytes')) {
// place, that is not helpful to us here.
// See random_bytes_dev_urandom.php
require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_dev_urandom.php';
}
// Unset variables after use
$RandomCompat_basedir = null;
@ -159,7 +159,7 @@ if (!is_callable('random_bytes')) {
extension_loaded('mcrypt')
) {
// See random_bytes_mcrypt.php
require_once $RandomCompatDIR . '/random_bytes_mcrypt.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_mcrypt.php';
}
$RandomCompatUrandom = null;
@ -184,7 +184,7 @@ if (!is_callable('random_bytes')) {
$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
// See random_bytes_com_dotnet.php
require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_com_dotnet.php';
}
} catch (com_exception $e) {
// Don't try to use it.
@ -204,6 +204,7 @@ if (!is_callable('random_bytes')) {
*
* @param mixed $length
* @psalm-suppress MissingReturnType
* @psalm-suppress InvalidReturnType
* @throws Exception
* @return string
*/
@ -219,7 +220,7 @@ if (!is_callable('random_bytes')) {
}
if (!is_callable('random_int')) {
require_once $RandomCompatDIR . '/random_int.php';
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_int.php';
}
$RandomCompatDIR = null;

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -7,7 +7,7 @@ if (!is_callable('random_int')) {
*
* The MIT License (MIT)
*
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -129,7 +129,7 @@ class ParagonIE_Sodium_Compat
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_bin2hex($string);
}
if (self::use_fallback('bin2hex')) {
@ -157,7 +157,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (int) sodium_compare($left, $right);
}
if (self::use_fallback('compare')) {
@ -176,7 +176,7 @@ class ParagonIE_Sodium_Compat
*/
public static function crypto_aead_aes256gcm_is_available()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_aead_aes256gcm_is_available();
}
if (self::use_fallback('crypto_aead_aes256gcm_is_available')) {
@ -361,7 +361,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -438,7 +438,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_aead_chacha20poly1305_encrypt(
$plaintext,
$assocData,
@ -515,7 +515,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -603,7 +603,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
$plaintext,
$assocData,
@ -800,7 +800,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_AUTH_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_auth($message, $key);
}
if (self::use_fallback('crypto_auth')) {
@ -847,7 +847,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_AUTH_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (bool) sodium_crypto_auth_verify($mac, $message, $key);
}
if (self::use_fallback('crypto_auth_verify')) {
@ -891,7 +891,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box($plaintext, $nonce, $keypair);
}
if (self::use_fallback('crypto_box')) {
@ -931,7 +931,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_seal($plaintext, $publicKey);
}
if (self::use_fallback('crypto_box_seal')) {
@ -969,7 +969,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -998,7 +998,7 @@ class ParagonIE_Sodium_Compat
*/
public static function crypto_box_keypair()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_keypair();
}
if (self::use_fallback('crypto_box_keypair')) {
@ -1032,7 +1032,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_keypair_from_secretkey_and_publickey($secretKey, $publicKey);
}
if (self::use_fallback('crypto_box_keypair_from_secretkey_and_publickey')) {
@ -1075,7 +1075,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -1110,7 +1110,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_publickey($keypair);
}
if (self::use_fallback('crypto_box_publickey')) {
@ -1141,7 +1141,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_publickey_from_secretkey($secretKey);
}
if (self::use_fallback('crypto_box_publickey_from_secretkey')) {
@ -1172,7 +1172,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_secretkey($keypair);
}
if (self::use_fallback('crypto_box_secretkey')) {
@ -1199,7 +1199,7 @@ class ParagonIE_Sodium_Compat
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_box_seed_keypair($seed);
}
if (self::use_fallback('crypto_box_seed_keypair')) {
@ -1244,7 +1244,7 @@ class ParagonIE_Sodium_Compat
}
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_generichash($message, $key, $length);
}
if (self::use_fallback('crypto_generichash')) {
@ -1272,7 +1272,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_generichash_final($ctx, $length);
}
if (self::use_fallback('crypto_generichash_final')) {
@ -1322,7 +1322,7 @@ class ParagonIE_Sodium_Compat
}
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_generichash_init($key, $length);
}
if (self::use_fallback('crypto_generichash_init')) {
@ -1351,7 +1351,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
sodium_crypto_generichash_update($ctx, $message);
return;
}
@ -1426,7 +1426,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 4 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
if (is_callable('sodium_crypto_kx')) {
return (string) sodium_crypto_kx(
$my_secret,
@ -1481,7 +1481,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
if (!is_null($alg)) {
ParagonIE_Sodium_Core_Util::declareScalarType($alg, 'int', 6);
return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg);
@ -1507,7 +1507,7 @@ class ParagonIE_Sodium_Compat
*/
public static function crypto_pwhash_is_available()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return true;
}
if (self::use_fallback('crypto_pwhash')) {
@ -1531,7 +1531,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit);
}
if (self::use_fallback('crypto_pwhash_str')) {
@ -1556,7 +1556,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (bool) sodium_crypto_pwhash_str_verify($passwd, $hash);
}
if (self::use_fallback('crypto_pwhash_str_verify')) {
@ -1586,7 +1586,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
}
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
@ -1608,7 +1608,7 @@ class ParagonIE_Sodium_Compat
*/
public static function crypto_pwhash_scryptsalsa208sha256_is_available()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return true;
}
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
@ -1631,7 +1631,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
}
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str')) {
@ -1655,7 +1655,7 @@ class ParagonIE_Sodium_Compat
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (bool) sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
}
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str_verify')) {
@ -1694,7 +1694,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_scalarmult($secretKey, $publicKey);
}
if (self::use_fallback('crypto_scalarmult')) {
@ -1734,7 +1734,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_scalarmult_base($secretKey);
}
if (self::use_fallback('crypto_scalarmult_base')) {
@ -1777,7 +1777,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_secretbox($plaintext, $nonce, $key);
}
if (self::use_fallback('crypto_secretbox')) {
@ -1817,7 +1817,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -1930,7 +1930,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_SHORTHASH_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_shorthash($message, $key);
}
if (self::use_fallback('crypto_shorthash')) {
@ -1978,7 +1978,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign($message, $secretKey);
}
if (self::use_fallback('crypto_sign')) {
@ -2017,7 +2017,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
@ -2042,7 +2042,7 @@ class ParagonIE_Sodium_Compat
*/
public static function crypto_sign_keypair()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_keypair();
}
if (self::use_fallback('crypto_sign_keypair')) {
@ -2067,7 +2067,7 @@ class ParagonIE_Sodium_Compat
{
ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_seed_keypair($seed);
}
if (self::use_fallback('crypto_sign_keypair')) {
@ -2102,7 +2102,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_publickey($keypair);
}
if (self::use_fallback('crypto_sign_publickey')) {
@ -2133,7 +2133,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_publickey_from_secretkey($secretKey);
}
if (self::use_fallback('crypto_sign_publickey_from_secretkey')) {
@ -2164,7 +2164,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_secretkey($keypair);
}
if (self::use_fallback('crypto_sign_secretkey')) {
@ -2199,7 +2199,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_detached($message, $secretKey);
}
if (self::use_fallback('crypto_sign_detached')) {
@ -2238,7 +2238,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_sign_verify_detached($signature, $message, $publicKey);
}
if (self::use_fallback('crypto_sign_verify_detached')) {
@ -2268,7 +2268,7 @@ class ParagonIE_Sodium_Compat
if (ParagonIE_Sodium_Core_Util::strlen($pk) < self::CRYPTO_SIGN_PUBLICKEYBYTES) {
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_PUBLICKEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
if (is_callable('crypto_sign_ed25519_pk_to_curve25519')) {
return (string) sodium_crypto_sign_ed25519_pk_to_curve25519($pk);
}
@ -2300,7 +2300,7 @@ class ParagonIE_Sodium_Compat
if (ParagonIE_Sodium_Core_Util::strlen($sk) < self::CRYPTO_SIGN_SEEDBYTES) {
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_SEEDBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
if (is_callable('crypto_sign_ed25519_sk_to_curve25519')) {
return sodium_crypto_sign_ed25519_sk_to_curve25519($sk);
}
@ -2348,7 +2348,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_STREAM_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_stream($len, $nonce, $key);
}
if (self::use_fallback('crypto_stream')) {
@ -2395,7 +2395,7 @@ class ParagonIE_Sodium_Compat
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
}
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_crypto_stream_xor($message, $nonce, $key);
}
if (self::use_fallback('crypto_stream_xor')) {
@ -2432,7 +2432,7 @@ class ParagonIE_Sodium_Compat
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
if (is_callable('sodium_hex2bin')) {
return (string) sodium_hex2bin($string);
}
@ -2458,7 +2458,7 @@ class ParagonIE_Sodium_Compat
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
sodium_increment($var);
return;
}
@ -2490,7 +2490,7 @@ class ParagonIE_Sodium_Compat
*/
public static function library_version_major()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_library_version_major();
}
if (self::use_fallback('library_version_major')) {
@ -2509,7 +2509,7 @@ class ParagonIE_Sodium_Compat
*/
public static function library_version_minor()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return sodium_library_version_minor();
}
if (self::use_fallback('library_version_minor')) {
@ -2558,7 +2558,7 @@ class ParagonIE_Sodium_Compat
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
sodium_memzero($var);
return;
}
@ -2643,7 +2643,7 @@ class ParagonIE_Sodium_Compat
*/
public static function version_string()
{
if (self::isPhp72OrGreater()) {
if (self::useNewSodiumAPI()) {
return (string) sodium_version_string();
}
if (self::use_fallback('version_string')) {
@ -2686,15 +2686,16 @@ class ParagonIE_Sodium_Compat
/**
* Libsodium as implemented in PHP 7.2
* and/or ext/sodium (via PECL)
*
* @ref https://wiki.php.net/rfc/libsodium
* @return bool
*/
protected static function isPhp72OrGreater()
protected static function useNewSodiumAPI()
{
static $res = null;
if ($res === null) {
$res = PHP_VERSION_ID >= 70200 && extension_loaded('sodium');
$res = PHP_VERSION_ID >= 70000 && extension_loaded('sodium');
}
if (self::$disableFallbackForUnitTests) {
// Don't fallback. Use the PHP implementation.

View File

@ -10,7 +10,7 @@ if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
class ParagonIE_Sodium_Core_ChaCha20_Ctx extends ParagonIE_Sodium_Core_Util implements ArrayAccess
{
/**
* @var SplFixedArray<int, int>
* @var SplFixedArray internally, <int, int>
*/
protected $container;

View File

@ -33,7 +33,7 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
$v[3] ^= $v[1];
# v0=ROTL(v0,32);
list($v[0], $v[1]) = self::rotl_64($v[0], $v[1], 32);
list($v[0], $v[1]) = self::rotl_64((int) $v[0], (int) $v[1], 32);
# v2 += v3;
list($v[4], $v[5]) = self::add(
@ -50,12 +50,12 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
# v0 += v3;
list($v[0], $v[1]) = self::add(
array($v[0], $v[1]),
array($v[6], $v[7])
array((int) $v[0], (int) $v[1]),
array((int) $v[6], (int) $v[7])
);
# v3=ROTL(v3,21);
list($v[6], $v[7]) = self::rotl_64($v[6], $v[7], 21);
list($v[6], $v[7]) = self::rotl_64((int) $v[6], (int) $v[7], 21);
# v3 ^= v0;
$v[6] ^= $v[0];
@ -63,19 +63,19 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
# v2 += v1;
list($v[4], $v[5]) = self::add(
array($v[4], $v[5]),
array($v[2], $v[3])
array((int) $v[4], (int) $v[5]),
array((int) $v[2], (int) $v[3])
);
# v1=ROTL(v1,17);
list($v[2], $v[3]) = self::rotl_64($v[2], $v[3], 17);
list($v[2], $v[3]) = self::rotl_64((int) $v[2], (int) $v[3], 17);
# v1 ^= v2;;
$v[2] ^= $v[4];
$v[3] ^= $v[5];
# v2=ROTL(v2,32)
list($v[4], $v[5]) = self::rotl_64($v[4], $v[5], 32);
list($v[4], $v[5]) = self::rotl_64((int) $v[4], (int) $v[5], 32);
return $v;
}

View File

@ -10,7 +10,7 @@ if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess
{
/**
* @var SplFixedArray<int, ParagonIE_Sodium_Core32_Int32>
* @var SplFixedArray internally, <int, ParagonIE_Sodium_Core32_Int32>
*/
protected $container;

View File

@ -218,12 +218,11 @@ class Command
if (null !== $this->processTitle) {
if (function_exists('cli_set_process_title')) {
if (false === @cli_set_process_title($this->processTitle)) {
if (!@cli_set_process_title($this->processTitle)) {
if ('Darwin' === PHP_OS) {
$output->writeln('<comment>Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.</comment>');
} else {
$error = error_get_last();
trigger_error($error['message'], E_USER_WARNING);
cli_set_process_title($this->processTitle);
}
}
} elseif (function_exists('setproctitle')) {

View File

@ -121,7 +121,7 @@ class JsonDescriptor extends Descriptor
{
return array(
'name' => '--'.$option->getName(),
'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '',
'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
'accept_value' => $option->acceptValue(),
'is_value_required' => $option->isValueRequired(),
'is_multiple' => $option->isArray(),

View File

@ -70,7 +70,7 @@ class MarkdownDescriptor extends Descriptor
{
$name = '--'.$option->getName();
if ($option->getShortcut()) {
$name .= '|-'.implode('|-', explode('|', $option->getShortcut())).'';
$name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
}
$this->write(

View File

@ -224,7 +224,7 @@ class XmlDescriptor extends Descriptor
$pos = strpos($option->getShortcut(), '|');
if (false !== $pos) {
$objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
$objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut())));
$objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
} else {
$objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
}

View File

@ -40,10 +40,10 @@ class ErrorListener implements EventSubscriberInterface
$error = $event->getError();
if (!$inputString = $this->getInputString($event)) {
return $this->logger->error('An error occurred while using the console. Message: "{message}"', array('error' => $error, 'message' => $error->getMessage()));
return $this->logger->error('An error occurred while using the console. Message: "{message}"', array('exception' => $error, 'message' => $error->getMessage()));
}
$this->logger->error('Error thrown while running command "{command}". Message: "{message}"', array('error' => $error, 'command' => $inputString, 'message' => $error->getMessage()));
$this->logger->error('Error thrown while running command "{command}". Message: "{message}"', array('exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()));
}
public function onConsoleTerminate(ConsoleTerminateEvent $event)

View File

@ -305,7 +305,7 @@ class QuestionHelper extends Helper
foreach ($autocomplete as $value) {
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
if (0 === strpos($value, $ret) && $i !== strlen($value)) {
if (0 === strpos($value, $ret)) {
$matches[$numMatches++] = $value;
}
}

View File

@ -195,7 +195,7 @@ class InputOption
*
* @return bool
*/
public function equals(InputOption $option)
public function equals(self $option)
{
return $option->getName() === $this->getName()
&& $option->getShortcut() === $this->getShortcut()

View File

@ -83,31 +83,34 @@ class StreamOutput extends Output
*
* Colorization is disabled if not supported by the stream:
*
* - the stream is redirected (eg php file.php >log)
* - Windows without VT100 support, Ansicon, ConEmu, Mintty
* - non tty consoles
* This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo
* terminals via named pipes, so we can only check the environment.
*
* Reference: Composer\XdebugHandler\Process::supportsColor
* https://github.com/composer/xdebug-handler
*
* @return bool true if the stream supports colorization, false otherwise
*/
protected function hasColorSupport()
{
if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) {
return false;
}
if (DIRECTORY_SEPARATOR === '\\') {
if (function_exists('sapi_windows_vt100_support')) {
$vt100Enabled = @sapi_windows_vt100_support($this->stream);
} else {
$vt100Enabled = '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
}
return
$vt100Enabled
return (function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support($this->stream))
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM');
}
return function_exists('posix_isatty') && @posix_isatty($this->stream);
if (function_exists('stream_isatty')) {
return @stream_isatty($this->stream);
}
if (function_exists('posix_isatty')) {
return @posix_isatty($this->stream);
}
$stat = @fstat($this->stream);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
}

View File

@ -383,14 +383,16 @@ class ErrorHandler
public function handleError($type, $message, $file, $line)
{
// Level is the current error reporting level to manage silent error.
$level = error_reporting();
$silenced = 0 === ($level & $type);
// Strong errors are not authorized to be silenced.
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$log = $this->loggedErrors & $type;
$throw = $this->thrownErrors & $type & $level;
$type &= $level | $this->screamedErrors;
if (!$type || (!$log && !$throw)) {
return $type && $log;
return !$silenced && $type && $log;
}
$scope = $this->scopedErrors & $type;
@ -524,7 +526,7 @@ class ErrorHandler
}
}
return $type && $log;
return !$silenced && $type && $log;
}
/**

View File

@ -157,7 +157,7 @@ class FlattenException
return $this->previous;
}
public function setPrevious(FlattenException $previous)
public function setPrevious(self $previous)
{
$this->previous = $previous;
}

View File

@ -40,7 +40,7 @@ class ExceptionHandler
{
$this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->fileLinkFormat = $fileLinkFormat;
}
/**
@ -355,13 +355,29 @@ EOF;
private function formatPath($path, $line)
{
$file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path);
$fmt = $this->fileLinkFormat;
$fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
if ($fmt && $link = is_string($fmt) ? strtr($fmt, array('%f' => $path, '%l' => $line)) : $fmt->format($path, $line)) {
return sprintf('<span class="block trace-file-path">in <a href="%s" title="Go to source">%s (line %d)</a></span>', $this->escapeHtml($link), $file, $line);
if (!$fmt) {
return sprintf('<span class="block trace-file-path">in <a title="%s%3$s"><strong>%s</strong>%s</a></span>', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
}
return sprintf('<span class="block trace-file-path">in <a title="%s line %3$d"><strong>%s</strong> (line %d)</a></span>', $this->escapeHtml($path), $file, $line);
if (\is_string($fmt)) {
$i = strpos($f = $fmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f);
$fmt = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 1; isset($fmt[$i]); ++$i) {
if (0 === strpos($path, $k = $fmt[$i++])) {
$path = substr_replace($path, $fmt[$i], 0, strlen($k));
break;
}
}
$link = strtr($fmt[0], array('%f' => $path, '%l' => $line));
} else {
$link = $fmt->format($path, $line);
}
return sprintf('<span class="block trace-file-path">in <a href="%s" title="Go to source"><strong>%s</string>%s</a></span>', $this->escapeHtml($link), $file, 0 < $line ? ' line '.$line : '');
}
/**

View File

@ -0,0 +1,227 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Polyfill\Ctype;
/**
* Ctype implementation through regex.
*
* @internal
*
* @author Gert de Pagter <BackEndTea@gmail.com>
*/
final class Ctype
{
/**
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
*
* @see https://php.net/ctype-alnum
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_alnum($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
}
/**
* Returns TRUE if every character in text is a letter, FALSE otherwise.
*
* @see https://php.net/ctype-alpha
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_alpha($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
}
/**
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
*
* @see https://php.net/ctype-cntrl
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_cntrl($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
}
/**
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
*
* @see https://php.net/ctype-digit
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_digit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
}
/**
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
*
* @see https://php.net/ctype-graph
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_graph($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
}
/**
* Returns TRUE if every character in text is a lowercase letter.
*
* @see https://php.net/ctype-lower
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_lower($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
}
/**
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
*
* @see https://php.net/ctype-print
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_print($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
}
/**
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
*
* @see https://php.net/ctype-punct
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_punct($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
}
/**
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
*
* @see https://php.net/ctype-space
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_space($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
}
/**
* Returns TRUE if every character in text is an uppercase letter.
*
* @see https://php.net/ctype-upper
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_upper($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
}
/**
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
*
* @see https://php.net/ctype-xdigit
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_xdigit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
}
/**
* Converts integers to their char versions according to normal ctype behaviour, if needed.
*
* If an integer between -128 and 255 inclusive is provided,
* it is interpreted as the ASCII value of a single character
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
* Any other integer is interpreted as a string containing the decimal digits of the integer.
*
* @param string|int $int
*
* @return mixed
*/
private static function convert_int_to_char_for_ctype($int)
{
if (!\is_int($int)) {
return $int;
}
if ($int < -128 || $int > 255) {
return (string) $int;
}
if ($int < 0) {
$int += 256;
}
return \chr($int);
}
}

View File

@ -0,0 +1,19 @@
Copyright (c) 2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Polyfill\Ctype as p;
if (!function_exists('ctype_alnum')) {
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
function ctype_print($text) { return p\Ctype::ctype_print($text); }
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
function ctype_space($text) { return p\Ctype::ctype_space($text); }
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
}

View File

@ -78,7 +78,7 @@ final class Mbstring
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
{
if (is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
} else {
$fromEncoding = self::getEncoding($fromEncoding);
@ -140,16 +140,16 @@ final class Mbstring
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
{
if (null !== $s && !is_scalar($s) && !(is_object($s) && method_exists($s, '__toString'))) {
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING);
return null;
}
if (!is_array($convmap) || !$convmap) {
if (!\is_array($convmap) || !$convmap) {
return false;
}
if (null !== $encoding && !is_scalar($encoding)) {
if (null !== $encoding && !\is_scalar($encoding)) {
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING);
return ''; // Instead of null (cf. mb_encode_numericentity).
}
@ -170,7 +170,7 @@ final class Mbstring
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
}
$cnt = floor(count($convmap) / 4) * 4;
$cnt = floor(\count($convmap) / 4) * 4;
for ($i = 0; $i < $cnt; $i += 4) {
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
@ -197,21 +197,21 @@ final class Mbstring
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
{
if (null !== $s && !is_scalar($s) && !(is_object($s) && method_exists($s, '__toString'))) {
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING);
return null;
}
if (!is_array($convmap) || !$convmap) {
if (!\is_array($convmap) || !$convmap) {
return false;
}
if (null !== $encoding && !is_scalar($encoding)) {
if (null !== $encoding && !\is_scalar($encoding)) {
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING);
return null; // Instead of '' (cf. mb_decode_numericentity).
}
if (null !== $is_hex && !is_scalar($is_hex)) {
if (null !== $is_hex && !\is_scalar($is_hex)) {
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.gettype($s).' given', E_USER_WARNING);
return null;
}
@ -234,9 +234,9 @@ final class Mbstring
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
$cnt = floor(count($convmap) / 4) * 4;
$cnt = floor(\count($convmap) / 4) * 4;
$i = 0;
$len = strlen($s);
$len = \strlen($s);
$result = '';
while ($i < $len) {
@ -305,7 +305,7 @@ final class Mbstring
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
$i = 0;
$len = strlen($s);
$len = \strlen($s);
while ($i < $len) {
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
@ -314,7 +314,7 @@ final class Mbstring
if (isset($map[$uchr])) {
$uchr = $map[$uchr];
$nlen = strlen($uchr);
$nlen = \strlen($uchr);
if ($nlen == $ulen) {
$nlen = $i;
@ -404,7 +404,7 @@ final class Mbstring
if (null === $encodingList) {
$encodingList = self::$encodingList;
} else {
if (!is_array($encodingList)) {
if (!\is_array($encodingList)) {
$encodingList = array_map('trim', explode(',', $encodingList));
}
$encodingList = array_map('strtoupper', $encodingList);
@ -441,7 +441,7 @@ final class Mbstring
return self::$encodingList;
}
if (!is_array($encodingList)) {
if (!\is_array($encodingList)) {
$encodingList = array_map('trim', explode(',', $encodingList));
}
$encodingList = array_map('strtoupper', $encodingList);
@ -467,7 +467,7 @@ final class Mbstring
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return strlen($s);
return \strlen($s);
}
return @iconv_strlen($s, $encoding);
@ -679,13 +679,13 @@ final class Mbstring
public static function mb_chr($code, $encoding = null)
{
if (0x80 > $code %= 0x200000) {
$s = chr($code);
$s = \chr($code);
} elseif (0x800 > $code) {
$s = chr(0xC0 | $code >> 6).chr(0x80 | $code & 0x3F);
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
} elseif (0x10000 > $code) {
$s = chr(0xE0 | $code >> 12).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F);
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
} else {
$s = chr(0xF0 | $code >> 18).chr(0x80 | $code >> 12 & 0x3F).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F);
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
}
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
@ -735,7 +735,7 @@ final class Mbstring
while (isset($m[$i])) {
if (0x80 > $m[$i]) {
$entities .= chr($m[$i++]);
$entities .= \chr($m[$i++]);
continue;
}
if (0xF0 <= $m[$i]) {

View File

@ -12,6 +12,8 @@
namespace Symfony\Component\Yaml\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@ -86,14 +88,14 @@ EOF
if (!$filename) {
if (!$stdin = $this->getStdin()) {
throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}
return $this->display($io, array($this->validate($stdin, $flags)));
}
if (!$this->isReadable($filename)) {
throw new \RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
}
$filesInfo = array();
@ -133,7 +135,7 @@ EOF
case 'json':
return $this->displayJson($io, $files);
default:
throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
}
}

View File

@ -324,6 +324,9 @@ class Inline
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), ' ');
if ('' === $tmp) {
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (!in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}

View File

@ -12,6 +12,14 @@ namespace Zend\Diactoros;
use Psr\Http\Message\StreamInterface;
use UnexpectedValueException;
use function array_pop;
use function implode;
use function ltrim;
use function preg_match;
use function sprintf;
use function str_replace;
use function ucwords;
/**
* Provides base functionality for request and response de/serialization
* strategies, including functionality for retrieving a line at a time from

View File

@ -10,8 +10,12 @@
namespace Zend\Diactoros;
use InvalidArgumentException;
use RuntimeException;
use Psr\Http\Message\StreamInterface;
use RuntimeException;
use function array_key_exists;
use const SEEK_SET;
/**
* Implementation of PSR HTTP streams

View File

@ -9,6 +9,17 @@ namespace Zend\Diactoros;
use InvalidArgumentException;
use function get_class;
use function gettype;
use function in_array;
use function is_numeric;
use function is_object;
use function is_string;
use function ord;
use function preg_match;
use function sprintf;
use function strlen;
/**
* Provide security tools around HTTP headers to prevent common injection vectors.
*

View File

@ -10,6 +10,19 @@ namespace Zend\Diactoros;
use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;
use function array_map;
use function array_merge;
use function get_class;
use function gettype;
use function implode;
use function is_array;
use function is_object;
use function is_resource;
use function is_string;
use function preg_match;
use function sprintf;
use function strtolower;
/**
* Trait implementing the various methods defined in MessageInterface.
*

Some files were not shown because too many files have changed in this diff Show More