From 5f05cdb26c3916d6ddb8c9d8647849025a81d24b Mon Sep 17 00:00:00 2001 From: Dennis Iversen Date: Mon, 7 Sep 2015 15:21:00 +0200 Subject: [PATCH 01/18] UTF8 error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efc20f328..390f5d1e5 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ They are documented in detail under [Annotations](ANNOTATIONS.md) ### 6. Authorize -In order to protect your api, authenticate and allow valid users +In order to protect your api, authenticate and allow valid users ```php Date: Tue, 20 Oct 2015 15:28:45 +0100 Subject: [PATCH 02/18] Fix: typos --- public/examples/_015_oauth2_server/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/examples/_015_oauth2_server/index.php b/public/examples/_015_oauth2_server/index.php index 3f00fa7e7..c867bf995 100755 --- a/public/examples/_015_oauth2_server/index.php +++ b/public/examples/_015_oauth2_server/index.php @@ -12,7 +12,7 @@ 1. run composer update to make sure you have - twig template library - - bshaffer's oauth2 libaray + - bshaffer's oauth2 libarary 2. make sure `public/examples/_015_oauth2_server/cache` has write permissions to create the compiled template files 3. make sure `public/examples/_015_oauth2_server/Auth/db` has write permission, this is where `oauth.sqlite` file be created at run time @@ -51,7 +51,7 @@ - **Implicit**: typically for browser based or mobile apps - **Authorization Code**: typically for apps running on a server -- **Password Credentials**: typically used for apps that are owned by the same organisation as the OAuth service +- **Password Credentials**: typically used for apps that are owned by the same organization as the OAuth service provider (aka, the Twitter client, etc.) - **Client Credentials**: used by client's who want to update meta information about their site (URL's, logo's, etc.) - **JWT Auth Grant**: the client submits a *JSON Web Token* in a request to the token endpoint. An access token @@ -136,4 +136,4 @@ $r = new Restler(); $r->addAuthenticationClass('Auth\\Server', ''); $r->setOverridingFormats('JsonFormat', 'HtmlFormat', 'UploadFormat'); -$r->handle(); \ No newline at end of file +$r->handle(); From a1b76c701cce8fa63142d8dc74911365b8d1b886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pina?= Date: Tue, 20 Oct 2015 16:16:08 +0100 Subject: [PATCH 03/18] fix library typo --- public/examples/_015_oauth2_server/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/examples/_015_oauth2_server/index.php b/public/examples/_015_oauth2_server/index.php index c867bf995..edc82a1ad 100755 --- a/public/examples/_015_oauth2_server/index.php +++ b/public/examples/_015_oauth2_server/index.php @@ -12,7 +12,7 @@ 1. run composer update to make sure you have - twig template library - - bshaffer's oauth2 libarary + - bshaffer's oauth2 library 2. make sure `public/examples/_015_oauth2_server/cache` has write permissions to create the compiled template files 3. make sure `public/examples/_015_oauth2_server/Auth/db` has write permission, this is where `oauth.sqlite` file be created at run time From ac780ed5f89babcd964f89beb0bd1be9c5c49889 Mon Sep 17 00:00:00 2001 From: Alexander Makhaev Date: Sat, 9 Jan 2016 19:21:18 +0900 Subject: [PATCH 04/18] Fix for #357 --- vendor/Luracast/Restler/AutoLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/AutoLoader.php b/vendor/Luracast/Restler/AutoLoader.php index 9bb34bad9..6e9a3dd17 100644 --- a/vendor/Luracast/Restler/AutoLoader.php +++ b/vendor/Luracast/Restler/AutoLoader.php @@ -263,7 +263,7 @@ private function loadAliases($className) * @return bool false unless className now exists */ private function loadLastResort($className, $loader = null) { - $loaders = array_unique(static::$rogueLoaders); + $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); if (isset($loader)) { if (false === array_search($loader, $loaders)) static::$rogueLoaders[] = $loader; From d7b76ba99d8e76b4e1ab70b67db92a92a200d993 Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Wed, 12 Oct 2016 17:09:19 +0200 Subject: [PATCH 05/18] Fix typo @pformat => @format --- public/annotations.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/annotations.html b/public/annotations.html index 9663ae22f..f6032c553 100644 --- a/public/annotations.html +++ b/public/annotations.html @@ -325,7 +325,7 @@

@format

Example:

-
@pformat HtmlFormat
+
@format HtmlFormat
 

IF you want to force the request and or response format for a specific api method @format comment can be used

@@ -364,4 +364,4 @@

@errorView

- \ No newline at end of file + From 581d8d6dc5d37f439765f89725a92f85e98f1826 Mon Sep 17 00:00:00 2001 From: Luracast Date: Wed, 11 Jan 2017 11:42:36 +0800 Subject: [PATCH 06/18] Fix: PHP 7 compatibility by renaming String class as Text --- features/bootstrap/RestContext.php | 4 ++-- .../Restler/Data/{String.php => Text.php} | 2 +- vendor/Luracast/Restler/Resources.php | 16 ++++++++-------- vendor/Luracast/Restler/Routes.php | 4 ++-- vendor/Luracast/Restler/UI/Forms.php | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) rename vendor/Luracast/Restler/Data/{String.php => Text.php} (99%) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 0f5cd0c1f..91fab2f3c 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1,7 +1,7 @@ _data); - if (!String::contains($data, $response)) + if (!Text::contains($data, $response)) throw new Exception("Response value does not contain '$response' only\n\n" . $this->echoLastResponse()); } diff --git a/vendor/Luracast/Restler/Data/String.php b/vendor/Luracast/Restler/Data/Text.php similarity index 99% rename from vendor/Luracast/Restler/Data/String.php rename to vendor/Luracast/Restler/Data/Text.php index 268ca40c1..803d9a761 100644 --- a/vendor/Luracast/Restler/Data/String.php +++ b/vendor/Luracast/Restler/Data/Text.php @@ -11,7 +11,7 @@ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://luracast.com/products/restler/ */ -class String +class Text { /** * Given haystack contains the needle or not? diff --git a/vendor/Luracast/Restler/Resources.php b/vendor/Luracast/Restler/Resources.php index 23d2407c4..420d26460 100644 --- a/vendor/Luracast/Restler/Resources.php +++ b/vendor/Luracast/Restler/Resources.php @@ -1,7 +1,7 @@ $tLen + 1 && $fullPath{$tLen + 1} != '{' && !String::beginsWith($fullPath, '{')) { + } elseif ($fLen > $tLen + 1 && $fullPath{$tLen + 1} != '{' && !Text::beginsWith($fullPath, '{')) { //when mapped to root exclude paths that have static parts //they are listed else where under that static part name continue; @@ -246,7 +246,7 @@ public function get($id = '') if (empty($exclude)) { if ($fullPath == $exclude) continue 2; - } elseif (String::beginsWith($fullPath, $exclude)) { + } elseif (Text::beginsWith($fullPath, $exclude)) { continue 2; } } @@ -891,7 +891,7 @@ public function index() } $this->_mapResources($allRoutes, $map, $version); foreach ($map as $path => $description) { - if (!String::contains($path, '{')) { + if (!Text::contains($path, '{')) { //add id $r->apis[] = array( 'path' => $path . $this->formatString, @@ -934,7 +934,7 @@ protected function _mapResources(array $allRoutes, array &$map, $version = 1) foreach ($allRoutes as $fullPath => $routes) { $path = explode('/', $fullPath); $resource = isset($path[0]) ? $path[0] : ''; - if ($resource == 'resources' || String::endsWith($resource, 'index')) + if ($resource == 'resources' || Text::endsWith($resource, 'index')) continue; foreach ($routes as $httpMethod => $route) { if (in_array($httpMethod, static::$excludedHttpMethods)) { @@ -948,7 +948,7 @@ protected function _mapResources(array $allRoutes, array &$map, $version = 1) if (empty($exclude)) { if ($fullPath == $exclude) continue 2; - } elseif (String::beginsWith($fullPath, $exclude)) { + } elseif (Text::beginsWith($fullPath, $exclude)) { continue 2; } } diff --git a/vendor/Luracast/Restler/Routes.php b/vendor/Luracast/Restler/Routes.php index 5b1128cb5..77209c7ac 100644 --- a/vendor/Luracast/Restler/Routes.php +++ b/vendor/Luracast/Restler/Routes.php @@ -2,7 +2,7 @@ namespace Luracast\Restler; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\String; +use Luracast\Restler\Data\Text; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -587,7 +587,7 @@ protected static function getTypeAndModel(ReflectionClass $class, array $scope) $children[$name] = $child; } } catch (Exception $e) { - if (String::endsWith($e->getFile(), 'CommentParser.php')) { + if (Text::endsWith($e->getFile(), 'CommentParser.php')) { throw new RestException(500, "Error while parsing comments of `$className` class. " . $e->getMessage()); } throw $e; diff --git a/vendor/Luracast/Restler/UI/Forms.php b/vendor/Luracast/Restler/UI/Forms.php index 289f40b6f..03a89dfbb 100644 --- a/vendor/Luracast/Restler/UI/Forms.php +++ b/vendor/Luracast/Restler/UI/Forms.php @@ -3,7 +3,7 @@ use Luracast\Restler\CommentParser; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\String; +use Luracast\Restler\Data\Text; use Luracast\Restler\Data\ValidationInfo; use Luracast\Restler\Defaults; use Luracast\Restler\Format\UploadFormat; @@ -292,7 +292,7 @@ public static function field(ValidationInfo $p, $dataOnly = false) $options[] = $option; } } elseif ($p->type == 'boolean' || $p->type == 'bool') { - if (String::beginsWith($type, 'radio')) { + if (Text::beginsWith($type, 'radio')) { $options[] = array('name' => $p->name, 'text' => ' Yes ', 'value' => 'true'); $options[] = array('name' => $p->name, 'text' => ' No ', @@ -411,7 +411,7 @@ public function __isAllowed() if (empty($exclude)) { if ($url == $exclude) return true; - } elseif (String::beginsWith($url, $exclude)) { + } elseif (Text::beginsWith($url, $exclude)) { return true; } } From e94da23dae0d8524789c632404588cc668ec66bd Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 20 Mar 2017 17:02:16 +0900 Subject: [PATCH 07/18] Fix typo --- ANNOTATIONS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ANNOTATIONS.md b/ANNOTATIONS.md index 2f307c4f9..ae980cd2c 100644 --- a/ANNOTATIONS.md +++ b/ANNOTATIONS.md @@ -179,7 +179,7 @@ iValueObject. @var int policy age {@min 18} {@max 100} When an api method is returning or having one of the parameters as an instance -of a custom class @var comments can be used with properties of that class. +of a custom class @var comments can be used with properties of that class. They will be used for validation and documentation. Supported child attributes are same as that of @param so they are documented under [@param](PARAM.md) @@ -223,4 +223,4 @@ Specify the view file to be loaded by HtmlFormat for the given api method as rel Similar to the `@view` but only used when an exception is thrown ---------------- \ No newline at end of file +--------------- From 3d454c8280995a941b968a424208ac0d70f1e299 Mon Sep 17 00:00:00 2001 From: Luracast Date: Thu, 16 Nov 2017 21:45:54 +0800 Subject: [PATCH 08/18] Fix for Notice: Only variables should be passed by reference in public/examples/_007_crud/DB/Session.php on line 58 --- public/examples/_007_crud/DB/Session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/examples/_007_crud/DB/Session.php b/public/examples/_007_crud/DB/Session.php index 844c6650c..37244983a 100755 --- a/public/examples/_007_crud/DB/Session.php +++ b/public/examples/_007_crud/DB/Session.php @@ -55,7 +55,8 @@ function delete ($id) $index = $this->find($id); if ($index === FALSE) return FALSE; - return array_shift(array_splice($_SESSION['rs'], $index, 1)); + $record = array_splice($_SESSION['rs'], $index, 1); + return array_shift($record); } private function install () { From 097608f0772ca42f2858820e8886533a3cb99232 Mon Sep 17 00:00:00 2001 From: Luracast Date: Thu, 16 Nov 2017 21:57:30 +0800 Subject: [PATCH 09/18] [BUGFIX] Fix PHP 7.2 compatibility. Object is a reserved keyword. Fixes #591 --- .../Restler/Data/{Object.php => Obj.php} | 2 +- vendor/Luracast/Restler/Format/CsvFormat.php | 26 ++++---- vendor/Luracast/Restler/Format/HtmlFormat.php | 4 +- vendor/Luracast/Restler/Format/JsonFormat.php | 10 +-- .../Luracast/Restler/Format/PlistFormat.php | 4 +- vendor/Luracast/Restler/Format/XmlFormat.php | 4 +- vendor/Luracast/Restler/Format/YamlFormat.php | 4 +- vendor/Luracast/Restler/Scope.php | 64 +++++++++---------- 8 files changed, 59 insertions(+), 59 deletions(-) rename vendor/Luracast/Restler/Data/{Object.php => Obj.php} (99%) diff --git a/vendor/Luracast/Restler/Data/Object.php b/vendor/Luracast/Restler/Data/Obj.php similarity index 99% rename from vendor/Luracast/Restler/Data/Object.php rename to vendor/Luracast/Restler/Data/Obj.php index b34f82f0b..5978dbae9 100644 --- a/vendor/Luracast/Restler/Data/Object.php +++ b/vendor/Luracast/Restler/Data/Obj.php @@ -13,7 +13,7 @@ * @link http://luracast.com/products/restler/ * @version 3.0.0rc5 */ -class Object +class Obj { /** * @var bool|string|callable diff --git a/vendor/Luracast/Restler/Format/CsvFormat.php b/vendor/Luracast/Restler/Format/CsvFormat.php index c0dedf1b5..265070562 100644 --- a/vendor/Luracast/Restler/Format/CsvFormat.php +++ b/vendor/Luracast/Restler/Format/CsvFormat.php @@ -2,7 +2,7 @@ namespace Luracast\Restler\Format; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; use Luracast\Restler\RestException; /** @@ -44,10 +44,10 @@ class CsvFormat extends Format implements iDecodeStream */ public function encode($data, $humanReadable = false) { - $char = Object::$separatorChar; - Object::$separatorChar = false; - $data = Object::toArray($data); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $data = Obj::toArray($data); + Obj::$separatorChar = $char; if (is_array($data) && array_values($data) == $data) { //if indexed array $lines = array(); @@ -109,10 +109,10 @@ public function decode($data) while (($row = static::getRow(array_shift($lines), $keys)) !== FALSE) $decoded [] = $row; - $char = Object::$separatorChar; - Object::$separatorChar = false; - $decoded = Object::toArray($decoded); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $decoded = Obj::toArray($decoded); + Obj::$separatorChar = $char; return $decoded; } @@ -172,10 +172,10 @@ public function decodeStream($stream) while (($row = static::getRow(stream_get_line($stream, 0, PHP_EOL), $keys)) !== FALSE) $decoded [] = $row; - $char = Object::$separatorChar; - Object::$separatorChar = false; - $decoded = Object::toArray($decoded); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $decoded = Obj::toArray($decoded); + Obj::$separatorChar = $char; return $decoded; } } \ No newline at end of file diff --git a/vendor/Luracast/Restler/Format/HtmlFormat.php b/vendor/Luracast/Restler/Format/HtmlFormat.php index 65d2bb627..c9679990d 100644 --- a/vendor/Luracast/Restler/Format/HtmlFormat.php +++ b/vendor/Luracast/Restler/Format/HtmlFormat.php @@ -11,7 +11,7 @@ use Illuminate\View\FileViewFinder; use Illuminate\View\View; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; use Luracast\Restler\Defaults; use Luracast\Restler\RestException; use Luracast\Restler\Restler; @@ -313,7 +313,7 @@ public function encode($data, $humanReadable = false) $success = is_null($exception); $error = $success ? null : $exception->getMessage(); $data = array( - 'response' => Object::toArray($data), + 'response' => Obj::toArray($data), 'stages' => $this->restler->getEvents(), 'success' => $success, 'error' => $error diff --git a/vendor/Luracast/Restler/Format/JsonFormat.php b/vendor/Luracast/Restler/Format/JsonFormat.php index 1b7fd938c..e853181af 100644 --- a/vendor/Luracast/Restler/Format/JsonFormat.php +++ b/vendor/Luracast/Restler/Format/JsonFormat.php @@ -1,7 +1,7 @@ formatJson($result); if (self::$unEscapedUnicode) { $result = preg_replace_callback('/\\\u(\w\w\w\w)/', @@ -110,7 +110,7 @@ public function decode($data) if (function_exists('json_last_error')) { switch (json_last_error()) { case JSON_ERROR_NONE : - return Object::toArray($decoded); + return Obj::toArray($decoded); break; case JSON_ERROR_DEPTH : $message = 'maximum stack depth exceeded'; @@ -137,7 +137,7 @@ public function decode($data) throw new RestException (400, 'Error parsing JSON'); } - return Object::toArray($decoded); + return Obj::toArray($decoded); } /** diff --git a/vendor/Luracast/Restler/Format/PlistFormat.php b/vendor/Luracast/Restler/Format/PlistFormat.php index 2c645eb0d..d01a1c338 100644 --- a/vendor/Luracast/Restler/Format/PlistFormat.php +++ b/vendor/Luracast/Restler/Format/PlistFormat.php @@ -1,7 +1,7 @@ toCFType( - Object::toArray($data) + Obj::toArray($data) ); $plist->add($guessedStructure); diff --git a/vendor/Luracast/Restler/Format/XmlFormat.php b/vendor/Luracast/Restler/Format/XmlFormat.php index 52fe50c67..172544806 100644 --- a/vendor/Luracast/Restler/Format/XmlFormat.php +++ b/vendor/Luracast/Restler/Format/XmlFormat.php @@ -1,7 +1,7 @@ openMemory(); $xml->startDocument('1.0', $this->charset); diff --git a/vendor/Luracast/Restler/Format/YamlFormat.php b/vendor/Luracast/Restler/Format/YamlFormat.php index d87ad7bbc..373247220 100644 --- a/vendor/Luracast/Restler/Format/YamlFormat.php +++ b/vendor/Luracast/Restler/Format/YamlFormat.php @@ -2,7 +2,7 @@ namespace Luracast\Restler\Format; use Symfony\Component\Yaml\Yaml; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; /** * YAML Format for Restler Framework @@ -24,7 +24,7 @@ class YamlFormat extends Format public function encode($data, $humanReadable = false) { // require_once 'sfyaml.php'; - return @Yaml::dump(Object::toArray($data)); + return @Yaml::dump(Obj::toArray($data)); } public function decode($data) diff --git a/vendor/Luracast/Restler/Scope.php b/vendor/Luracast/Restler/Scope.php index a6b1baae5..e6156c023 100644 --- a/vendor/Luracast/Restler/Scope.php +++ b/vendor/Luracast/Restler/Scope.php @@ -17,45 +17,45 @@ class Scope { public static $classAliases = array( - //Core - 'Restler' => 'Luracast\Restler\Restler', + //Core + 'Restler' => 'Luracast\Restler\Restler', - //Format classes - 'AmfFormat' => 'Luracast\Restler\Format\AmfFormat', - 'JsFormat' => 'Luracast\Restler\Format\JsFormat', - 'JsonFormat' => 'Luracast\Restler\Format\JsonFormat', - 'HtmlFormat' => 'Luracast\Restler\Format\HtmlFormat', - 'PlistFormat' => 'Luracast\Restler\Format\PlistFormat', - 'UploadFormat' => 'Luracast\Restler\Format\UploadFormat', - 'UrlEncodedFormat' => 'Luracast\Restler\Format\UrlEncodedFormat', - 'XmlFormat' => 'Luracast\Restler\Format\XmlFormat', - 'YamlFormat' => 'Luracast\Restler\Format\YamlFormat', - 'CsvFormat' => 'Luracast\Restler\Format\CsvFormat', - 'TsvFormat' => 'Luracast\Restler\Format\TsvFormat', + //Format classes + 'AmfFormat' => 'Luracast\Restler\Format\AmfFormat', + 'JsFormat' => 'Luracast\Restler\Format\JsFormat', + 'JsonFormat' => 'Luracast\Restler\Format\JsonFormat', + 'HtmlFormat' => 'Luracast\Restler\Format\HtmlFormat', + 'PlistFormat' => 'Luracast\Restler\Format\PlistFormat', + 'UploadFormat' => 'Luracast\Restler\Format\UploadFormat', + 'UrlEncodedFormat' => 'Luracast\Restler\Format\UrlEncodedFormat', + 'XmlFormat' => 'Luracast\Restler\Format\XmlFormat', + 'YamlFormat' => 'Luracast\Restler\Format\YamlFormat', + 'CsvFormat' => 'Luracast\Restler\Format\CsvFormat', + 'TsvFormat' => 'Luracast\Restler\Format\TsvFormat', - //Filter classes - 'RateLimit' => 'Luracast\Restler\Filter\RateLimit', + //Filter classes + 'RateLimit' => 'Luracast\Restler\Filter\RateLimit', - //UI classes - 'Forms' => 'Luracast\Restler\UI\Forms', - 'Nav' => 'Luracast\Restler\UI\Nav', - 'Emmet' => 'Luracast\Restler\UI\Emmet', - 'T' => 'Luracast\Restler\UI\Tags', + //UI classes + 'Forms' => 'Luracast\Restler\UI\Forms', + 'Nav' => 'Luracast\Restler\UI\Nav', + 'Emmet' => 'Luracast\Restler\UI\Emmet', + 'T' => 'Luracast\Restler\UI\Tags', - //API classes - 'Resources' => 'Luracast\Restler\Resources', + //API classes + 'Resources' => 'Luracast\Restler\Resources', - //Cache classes - 'HumanReadableCache' => 'Luracast\Restler\HumanReadableCache', - 'ApcCache' => 'Luracast\Restler\ApcCache', + //Cache classes + 'HumanReadableCache' => 'Luracast\Restler\HumanReadableCache', + 'ApcCache' => 'Luracast\Restler\ApcCache', - //Utility classes - 'Object' => 'Luracast\Restler\Data\Object', - 'String' => 'Luracast\Restler\Data\String', - 'Arr' => 'Luracast\Restler\Data\Arr', + //Utility classes + 'Obj' => 'Luracast\Restler\Data\Obj', + 'String' => 'Luracast\Restler\Data\String', + 'Arr' => 'Luracast\Restler\Data\Arr', - //Exception - 'RestException' => 'Luracast\Restler\RestException' + //Exception + 'RestException' => 'Luracast\Restler\RestException' ); public static $properties = array(); protected static $instances = array(); From cd0c21b4f7c0a99261ad618e90a5263483e78007 Mon Sep 17 00:00:00 2001 From: Luracast Date: Wed, 17 Jan 2018 16:18:17 +0800 Subject: [PATCH 10/18] [BUGFIX] making sure get source.php is not allow access files outside examples folder --- public/examples/resources/getsource.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/examples/resources/getsource.php b/public/examples/resources/getsource.php index 0a2104888..efc1c55c2 100755 --- a/public/examples/resources/getsource.php +++ b/public/examples/resources/getsource.php @@ -4,15 +4,19 @@ $require_comments = $file[0] == '.'; $file = '../' . $file; $filepath = realpath($file); - $basepath = realpath('../../'); - if (strpos($basepath, $filepath) === 0) { + $basepath = realpath('../../examples'); + if (strpos($filepath, $basepath) !== 0) { #trying to get the source outside restler examples die('not allowed'); } - if (!file_exists($file)) die('file not found'); + if (!file_exists($file)) { + die('file not found'); + } $text = file_get_contents($file); $file = pathinfo($file, PATHINFO_FILENAME) . '.php'; - if (!$require_comments) $text = strip_comments($text); + if (!$require_comments) { + $text = strip_comments($text); + } die($file . '
' . htmlspecialchars($text) . "
"); } else { die('no file specified'); From 188968f6a15796077350f1be9c461f8d02c559a8 Mon Sep 17 00:00:00 2001 From: Luracast Date: Fri, 16 Mar 2018 13:08:02 +0800 Subject: [PATCH 11/18] [BUGFIX] Fixes CommentParser to leave out 0 in @param and @var comments. Closes #504 --- vendor/Luracast/Restler/CommentParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/CommentParser.php b/vendor/Luracast/Restler/CommentParser.php index 839983b73..e86d1fbad 100644 --- a/vendor/Luracast/Restler/CommentParser.php +++ b/vendor/Luracast/Restler/CommentParser.php @@ -195,7 +195,7 @@ private function extractData($comment) list(, $param, $value) = preg_split('/\@|\s/', $line, 3) + array('', '', ''); list($value, $embedded) = $this->parseEmbeddedData($value); - $value = array_filter(preg_split('/\s+/msu', $value)); + $value = array_filter(preg_split('/\s+/msu', $value),'strlen'); $this->parseParam($param, $value, $embedded); } return $this->_data; From 80a17c19e5c0e94b150c41cc9a75190ac9179e51 Mon Sep 17 00:00:00 2001 From: Arul Kumaran Date: Sun, 5 May 2019 21:40:32 +0800 Subject: [PATCH 12/18] [BUGFIX] Fixes CommentParser to confirm value before treating it as an array. Closes #618 --- vendor/Luracast/Restler/CommentParser.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vendor/Luracast/Restler/CommentParser.php b/vendor/Luracast/Restler/CommentParser.php index e86d1fbad..c951fa3ef 100644 --- a/vendor/Luracast/Restler/CommentParser.php +++ b/vendor/Luracast/Restler/CommentParser.php @@ -273,13 +273,9 @@ private function parseParam($param, array $value, array $embedded) $value ); $data[$param] = $arr; - } else { - if (!is_string($value) && isset($value[self::$embeddedDataName]) - && isset($data[$param][self::$embeddedDataName]) - ) { - $value[self::$embeddedDataName] - += $data[$param][self::$embeddedDataName]; - } + } elseif (!is_string($value) && isset($value[self::$embeddedDataName]) && + isset($data[$param][self::$embeddedDataName])) { + $value[self::$embeddedDataName] += $data[$param][self::$embeddedDataName]; $data[$param] = $value + $data[$param]; } } From 87197eb53b2e429288e9a94d1f0ca9a03d5fbd6c Mon Sep 17 00:00:00 2001 From: Arul Kumaran Date: Sun, 12 May 2019 23:05:48 +0800 Subject: [PATCH 13/18] [BUGFIX] Fixes JsonFormat to use decode parameters properly and optimises decoding by avoiding Obj::toArray() Closes#621 --- vendor/Luracast/Restler/Format/JsonFormat.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/vendor/Luracast/Restler/Format/JsonFormat.php b/vendor/Luracast/Restler/Format/JsonFormat.php index e853181af..092453141 100644 --- a/vendor/Luracast/Restler/Format/JsonFormat.php +++ b/vendor/Luracast/Restler/Format/JsonFormat.php @@ -76,14 +76,11 @@ public function encode($data, $humanReadable = false) $result = preg_replace_callback('/\\\u(\w\w\w\w)/', function($matches) { - if (function_exists('mb_convert_encoding')) - { - return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16BE'); - } - else - { - return iconv('UTF-16BE','UTF-8',pack('H*', $matches[1])); - } + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16BE'); + } else { + return iconv('UTF-16BE', 'UTF-8', pack('H*', $matches[1])); + } } , $result); } @@ -106,11 +103,11 @@ public function decode($data) ); } } - $decoded = json_decode($data, $options); + $decoded = json_decode($data, true, 512, $options); if (function_exists('json_last_error')) { switch (json_last_error()) { case JSON_ERROR_NONE : - return Obj::toArray($decoded); + return $decoded; //Obj::toArray($decoded); break; case JSON_ERROR_DEPTH : $message = 'maximum stack depth exceeded'; @@ -137,7 +134,7 @@ public function decode($data) throw new RestException (400, 'Error parsing JSON'); } - return Obj::toArray($decoded); + return $decoded; //Obj::toArray($decoded); } /** From 9b2a8ccb45aa715b6653c4cd4cc56277474b8740 Mon Sep 17 00:00:00 2001 From: Arul Kumaran Date: Thu, 23 May 2019 11:31:32 +0800 Subject: [PATCH 14/18] Fixes associative array fixing logic to keep only their non numeric indices --- vendor/Luracast/Restler/Data/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/Data/Validator.php b/vendor/Luracast/Restler/Data/Validator.php index 5e1940ba1..2bdc1bae5 100644 --- a/vendor/Luracast/Restler/Data/Validator.php +++ b/vendor/Luracast/Restler/Data/Validator.php @@ -516,7 +516,7 @@ public static function validate($input, ValidationInfo $info, $full = null) if ($contentType == 'indexed') { $input = $info->filterArray($input, true); } elseif ($contentType == 'associative') { - $input = $info->filterArray($input, true); + $input = $info->filterArray($input, false); } } elseif ( $contentType == 'indexed' && From 75c984cf423750b7a960bfbab279b351c31c0baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Thu, 14 Nov 2019 12:16:20 +0500 Subject: [PATCH 15/18] Update Validator.php --- vendor/Luracast/Restler/Data/Validator.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vendor/Luracast/Restler/Data/Validator.php b/vendor/Luracast/Restler/Data/Validator.php index 2bdc1bae5..0f7da9d58 100644 --- a/vendor/Luracast/Restler/Data/Validator.php +++ b/vendor/Luracast/Restler/Data/Validator.php @@ -471,8 +471,12 @@ public static function validate($input, ValidationInfo $info, $full = null) case 'string' : if (!is_string($input)) { - $error .= '. Expecting alpha numeric value'; - break; + if ($info->fix) { + $input = strval($input); + } else { + $error .= '. Expecting alpha numeric value'; + break; + } } if ($info->required && $input === '') { $error = "$name is required."; @@ -623,4 +627,4 @@ public static function validate($input, ValidationInfo $info, $full = null) throw $e; } } -} \ No newline at end of file +} From b3400cf906e194a1ec24138ba673e9688ffbd871 Mon Sep 17 00:00:00 2001 From: Yaroslav Molchan Date: Mon, 3 Feb 2020 17:16:38 +0200 Subject: [PATCH 16/18] Remove curly brace syntax for PHP 7.4 support --- vendor/Luracast/Restler/Scope.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/Scope.php b/vendor/Luracast/Restler/Scope.php index e6156c023..fed5ade3b 100644 --- a/vendor/Luracast/Restler/Scope.php +++ b/vendor/Luracast/Restler/Scope.php @@ -171,7 +171,7 @@ public static function resolve($className, array $scope) return false; $divider = '\\'; $qualified = false; - if ($className{0} == $divider) { + if ($className[0] == $divider) { $qualified = trim($className, $divider); } elseif (array_key_exists($className, $scope)) { $qualified = $scope[$className]; From 3dc110b190478f71fa8001e252714f2fb83efaad Mon Sep 17 00:00:00 2001 From: Yaroslav Molchan Date: Thu, 13 Feb 2020 17:47:37 +0200 Subject: [PATCH 17/18] Fix PHP 7.4 support. --- vendor/Luracast/Restler/CommentParser.php | 12 ++++++------ vendor/Luracast/Restler/Format/XmlFormat.php | 2 +- vendor/Luracast/Restler/Resources.php | 6 +++--- vendor/Luracast/Restler/Restler.php | 4 ++-- vendor/Luracast/Restler/Routes.php | 6 +++--- vendor/Luracast/Restler/UI/Emmet.php | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/vendor/Luracast/Restler/CommentParser.php b/vendor/Luracast/Restler/CommentParser.php index c951fa3ef..062b955b4 100644 --- a/vendor/Luracast/Restler/CommentParser.php +++ b/vendor/Luracast/Restler/CommentParser.php @@ -149,7 +149,7 @@ private function extractData($comment) $addNewline = true; } continue; - } elseif ($line{0} == '@') { + } elseif ($line[0] == '@') { $mode = 2; $newParam = true; } @@ -330,7 +330,7 @@ private function parseEmbeddedData($subject) $data = $format->decode($str); } } else { // auto detect - if ($str{0} == '{') { + if ($str[0] == '{') { $d = json_decode($str, true); if (json_last_error() != JSON_ERROR_NONE) { throw new Exception('Error parsing embedded JSON data' @@ -398,7 +398,7 @@ private function formatAuthor(array $value) { $r = array(); $email = end($value); - if ($email{0} == '<') { + if ($email[0] == '<') { $email = substr($email, 1, -1); array_pop($value); $r['email'] = $email; @@ -423,7 +423,7 @@ private function formatParam(array $value) $data = array_shift($value); if (empty($data)) { $r['type'] = 'mixed'; - } elseif ($data{0} == '$') { + } elseif ($data[0] == '$') { $r['name'] = substr($data, 1); $r['type'] = 'mixed'; } else { @@ -431,7 +431,7 @@ private function formatParam(array $value) $r['type'] = count($data) == 1 ? $data[0] : $data; $data = array_shift($value); - if (!empty($data) && $data{0} == '$') { + if (!empty($data) && $data[0] == '$') { $r['name'] = substr($data, 1); } } @@ -447,7 +447,7 @@ private function formatVar(array $value) $data = array_shift($value); if (empty($data)) { $r['type'] = 'mixed'; - } elseif ($data{0} == '$') { + } elseif ($data[0] == '$') { $r['name'] = substr($data, 1); $r['type'] = 'mixed'; } else { diff --git a/vendor/Luracast/Restler/Format/XmlFormat.php b/vendor/Luracast/Restler/Format/XmlFormat.php index 172544806..07e843382 100644 --- a/vendor/Luracast/Restler/Format/XmlFormat.php +++ b/vendor/Luracast/Restler/Format/XmlFormat.php @@ -233,7 +233,7 @@ public function decode($data) $namespaces = $xml->getNamespaces(); if (count($namespaces)) { $p = strpos($data, $xml->getName()); - if ($p && $data{$p - 1} == ':') { + if ($p && $data[$p - 1] == ':') { $s = strpos($data, '<') + 1; $prefix = substr($data, $s, $p - $s - 1); static::$namespacedProperties[static::$rootName] = $prefix; diff --git a/vendor/Luracast/Restler/Resources.php b/vendor/Luracast/Restler/Resources.php index 420d26460..f3cbcf662 100644 --- a/vendor/Luracast/Restler/Resources.php +++ b/vendor/Luracast/Restler/Resources.php @@ -198,7 +198,7 @@ public function get($id = '') } elseif (false !== ($pos = strpos($id, '-v'))) { //$version = intval(substr($id, $pos + 2)); $id = substr($id, 0, $pos); - } elseif ($id{0} == 'v' && is_numeric($v = substr($id, 1))) { + } elseif ($id[0] == 'v' && is_numeric($v = substr($id, 1))) { $id = ''; //$version = $v; } elseif ($id == 'root' || $id == 'index') { @@ -233,7 +233,7 @@ public function get($id = '') if ($tSlash) { if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) continue; - } elseif ($fLen > $tLen + 1 && $fullPath{$tLen + 1} != '{' && !Text::beginsWith($fullPath, '{')) { + } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) { //when mapped to root exclude paths that have static parts //they are listed else where under that static part name continue; @@ -275,7 +275,7 @@ public function get($id = '') if (count($parts) == 1 && $httpMethod == 'GET') { } else { for ($i = 0; $i < count($parts); $i++) { - if (strlen($parts[$i]) && $parts[$i]{0} == '{') { + if (strlen($parts[$i]) && $parts[$i][0] == '{') { $pos = $i - 1; break; } diff --git a/vendor/Luracast/Restler/Restler.php b/vendor/Luracast/Restler/Restler.php index 99c00a89e..ed62b23db 100644 --- a/vendor/Luracast/Restler/Restler.php +++ b/vendor/Luracast/Restler/Restler.php @@ -465,7 +465,7 @@ protected function getPath() '', $path ); - if (Defaults::$useUrlBasedVersioning && strlen($path) && $path{0} == 'v') { + if (Defaults::$useUrlBasedVersioning && strlen($path) && $path[0] == 'v') { $version = intval(substr($path, 1)); if ($version && $version <= $this->apiVersion) { $this->requestedApiVersion = $version; @@ -1380,7 +1380,7 @@ public function getEvents() */ public function __get($name) { - if ($name{0} == '_') { + if ($name[0] == '_') { $hiddenProperty = substr($name, 1); if (isset($this->$hiddenProperty)) { return $this->$hiddenProperty; diff --git a/vendor/Luracast/Restler/Routes.php b/vendor/Luracast/Restler/Routes.php index 77209c7ac..94fe08096 100644 --- a/vendor/Luracast/Restler/Routes.php +++ b/vendor/Luracast/Restler/Routes.php @@ -67,7 +67,7 @@ public static function addAPIClass($className, $resourcePath = '', $version = 1) foreach ($methods as $method) { $methodUrl = strtolower($method->getName()); //method name should not begin with _ - if ($methodUrl{0} == '_') { + if ($methodUrl[0] == '_') { continue; } $doc = $method->getDocComment(); @@ -304,7 +304,7 @@ public static function typeChar($type = null) if (!$type) { return 's'; } - switch ($type{0}) { + switch ($type[0]) { case 'i': case 'f': return 'n'; @@ -402,7 +402,7 @@ public static function find($path, $httpMethod, } $index = intval(substr($k, 1)); $details = $value[$httpMethod]['metadata']['param'][$index]; - if ($k{0} == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) { + if ($k[0] == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) { //remove the newlines $data[$details['name']] = trim($v, PHP_EOL); } else { diff --git a/vendor/Luracast/Restler/UI/Emmet.php b/vendor/Luracast/Restler/UI/Emmet.php index 658cdea91..e452453f6 100644 --- a/vendor/Luracast/Restler/UI/Emmet.php +++ b/vendor/Luracast/Restler/UI/Emmet.php @@ -350,7 +350,7 @@ public static function tokenize($string) $pos = strpos($string, $f, $start); $tokens = array(); for ($i = $start; $i < $pos; $i++) { - $token = $string{$i}; + $token = $string[$i]; if (('#' == $token || '.' == $token) && (!empty($tokens) || $i == 0) ) { @@ -362,7 +362,7 @@ public static function tokenize($string) $r[] = $f; } while (false != ($f = strtok(static::DELIMITERS))); for ($i = $pos; $i < strlen($string); $i++) { - $token = $string{$i}; + $token = $string[$i]; $r[] = $tokens[] = $token; } return $r; From c5ddd7095ccad5e67c5576fbbdcaa4fdf5732541 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 5 Mar 2020 04:09:44 -0300 Subject: [PATCH 18/18] Fix for POST/PUT/PATCH calls without bodies Those calls may be made only with path or query params, and still they fail validation because JSON refuses to decode an empty string. --- vendor/Luracast/Restler/Format/JsonFormat.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/Luracast/Restler/Format/JsonFormat.php b/vendor/Luracast/Restler/Format/JsonFormat.php index 092453141..986473242 100644 --- a/vendor/Luracast/Restler/Format/JsonFormat.php +++ b/vendor/Luracast/Restler/Format/JsonFormat.php @@ -90,6 +90,10 @@ function($matches) public function decode($data) { + if (!$data) { + return []; + } + $options = 0; if (self::$bigIntAsString) { if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) // PHP >= 5.4