@@ -137,21 +137,23 @@ public function get_curl_command($base_url, $additional = [])
137
137
$ type = (isset ($ this ->headers ['Content-Type ' ])) ? $ this ->headers ['Content-Type ' ] : null ;
138
138
139
139
$ options [] = '-X ' . $ this ->method ;
140
- if (is_string ($ this ->body )) {
141
- $ options [] = '--data-binary " ' . $ this ->body . '" ' ;
140
+ if (empty ($ this ->body )){
141
+ //NO-OP
142
+ }elseif (is_string ($ this ->body )) {
143
+ $ options [] = '--data-binary ' . escapeshellarg ($ this ->body );
142
144
} elseif (is_array ($ this ->body )) {
143
- $ options [] = '--data-binary " ' . join ('' , $ this ->body ) . ' " ' ;
145
+ $ options [] = '--data-binary ' . escapeshellarg ( join ('' , $ this ->body )) ;
144
146
} elseif (is_subclass_of ($ this ->struct , StructureElement::class)) {
145
147
foreach ($ this ->struct ->value as $ body ) {
146
- $ options [] = '--data-binary " ' . strip_tags ($ body ->print_request ($ type )) . ' " ' ;
148
+ $ options [] = '--data-binary ' . escapeshellarg ( strip_tags ($ body ->print_request ($ type ))) ;
147
149
}
148
150
}
149
151
foreach ($ this ->headers as $ header => $ value ) {
150
- $ options [] = '-H " ' . $ header . ': ' . $ value . ' " ' ;
152
+ $ options [] = '-H ' . escapeshellarg ( $ header . ': ' . $ value) ;
151
153
}
152
154
$ options = array_merge ($ options , $ additional );
153
155
154
- return htmlspecialchars ('curl ' . join (' ' , $ options ) . ' " ' . $ this ->parent ->build_url ($ base_url , true ) . ' " ' );
156
+ return htmlspecialchars ('curl ' . join (' ' , $ options ) . ' ' . escapeshellarg ( $ this ->parent ->build_url ($ base_url , true )) );
155
157
}
156
158
157
159
0 commit comments