Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7847a66

Browse files
authored
Merge pull requestmevdschee#326 from saraf/master
Handle leading whitespace in JSON body
2 parents9bbc5bb +b746794 commit7847a66

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎api.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ protected function findRelations($tables,$database,$auto_include) {
16791679
}
16801680

16811681
protectedfunctionretrieveInputs($data) {
1682+
$data =trim($data,"\t\n\r");
16821683
if (strlen($data)==0) {
16831684
$input =false;
16841685
}elseif ($data[0]=='{' ||$data[0]=='[') {

‎tests/Tests.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,14 @@ public function testEditPostWithApostrophe()
643643
$test->get('/posts/1');
644644
$test->expect('{"id":1,"user_id":1,"category_id":1,"content":"blog start\'d"}');
645645
}
646+
647+
publicfunctiontestAddPostWithLeadingWhitespaceInJSON()
648+
{
649+
$test =newApi($this);
650+
$test->post('/posts','
651+
{"user_id":1,"category_id":1,"content":"test whitespace"}');
652+
$test->expect('21');
653+
$test->get('/posts/21');
654+
$test->expect('{"id":21,"user_id":1,"category_id":1,"content":"test whitespace"}');
655+
}
646656
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp