File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
lib/private/AppFramework/Http
tests/lib/AppFramework/Http Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -431,13 +431,12 @@ protected function decodeContent() {
431431 // 'application/json' must be decoded manually.
432432 if (strpos ($ this ->getHeader ('Content-Type ' ), 'application/json ' ) !== false ) {
433433 $ params = json_decode (file_get_contents ($ this ->inputStream ), true );
434- if ($ params !== null && \count ($ params ) > 0 ) {
435- $ this ->items ['params ' ] = $ params ;
436- if ($ this ->method === 'POST ' ) {
437- $ this ->items ['post ' ] = $ params ;
434+ if (\is_array ($ params ) && \count ($ params ) > 0 ) {
435+ $ this ->items ['params ' ] = $ params ;
436+ if ($ this ->method === 'POST ' ) {
437+ $ this ->items ['post ' ] = $ params ;
438+ }
438439 }
439- }
440-
441440 // Handle application/x-www-form-urlencoded for methods other than GET
442441 // or post correctly
443442 } elseif ($ this ->method !== 'GET '
Original file line number Diff line number Diff line change @@ -207,9 +207,20 @@ public function testJsonPost() {
207207 $ this ->assertSame ('Joey ' , $ request ['nickname ' ]);
208208 }
209209
210- public function testNotJsonPost () {
210+ public function notJsonDataProvider () {
211+ return [
212+ ['this is not valid json ' ],
213+ ['"just a string" ' ],
214+ ['{"just a string"} ' ],
215+ ];
216+ }
217+
218+ /**
219+ * @dataProvider notJsonDataProvider
220+ */
221+ public function testNotJsonPost ($ testData ) {
211222 global $ data ;
212- $ data = ' this is not valid json ' ;
223+ $ data = $ testData ;
213224 $ vars = [
214225 'method ' => 'POST ' ,
215226 'server ' => ['CONTENT_TYPE ' => 'application/json; utf-8 ' ]
You can’t perform that action at this time.
0 commit comments