Skip to content

Commit 2de669e

Browse files
authored
Merge pull request php-curl-class#401 from zachborboa/master
Use sequential ids
2 parents 1d7af44 + 5cb8223 commit 2de669e

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (!is_website_url($url)) {
4444

4545
```bash
4646
# Attacker.
47-
$ curl https://www.example.com/upload_photo.php --data "photo=@/etc/password"
47+
$ curl https://www.example.com/upload_photo.php --data "photo=@/etc/passwd"
4848
```
4949

5050
```php

examples/multi_curl_get_load_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$limit = 1000;
3131
for ($i = 0; $i < $limit; $i++) {
3232
$url = $urls[mt_rand(0, count($urls) - 1)];
33-
$instance = $multi_curl->addGet($url);
33+
$multi_curl->addGet($url);
3434
}
3535

3636
$multi_curl->start();

src/Curl/MultiCurl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MultiCurl
1111
private $activeCurls = array();
1212
private $isStarted = false;
1313
private $concurrency = 25;
14+
private $nextCurlId = 0;
1415

1516
private $beforeSendFunction = null;
1617
private $successFunction = null;
@@ -736,6 +737,8 @@ public function __destruct()
736737
*/
737738
private function queueHandle($curl)
738739
{
740+
// Use sequential ids to allow for ordered post processing.
741+
$curl->id = $this->nextCurlId++;
739742
$this->curls[$curl->id] = $curl;
740743
}
741744

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,4 +2420,25 @@ public function testAddCurl()
24202420
$multi_curl->addCurl($curl);
24212421
$multi_curl->start();
24222422
}
2423+
2424+
public function testSequentialId()
2425+
{
2426+
$completed = array();
2427+
2428+
$multi_curl = new MultiCurl();
2429+
$multi_curl->complete(function ($instance) use (&$completed) {
2430+
$completed[] = $instance;
2431+
});
2432+
2433+
for ($i = 0; $i < 100; $i++) {
2434+
$multi_curl->addPost(Test::TEST_URL, $i);
2435+
}
2436+
2437+
$multi_curl->start();
2438+
2439+
foreach ($completed as $instance) {
2440+
$sequential_id = $instance->getOpt(CURLOPT_POSTFIELDS);
2441+
$this->assertEquals($sequential_id, $instance->id);
2442+
}
2443+
}
24232444
}

0 commit comments

Comments
 (0)