Skip to content

Commit 931c31f

Browse files
change error thrown for null byte issues (#1813)
1 parent 067658d commit 931c31f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/ApiRequestor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ private function _requestRaw($method, $url, $params, $headers, $apiMode, $usage)
519519
// for some reason, PHP users will sometimes include null bytes in their paths, which leads to cryptic server 400s.
520520
// we'll be louder about this to help catch issues earlier.
521521
if (false !== \strpos($absUrl, "\0") || false !== \strpos($absUrl, '%00')) {
522-
throw new Exception\BadMethodCallException("URLs may not contain null bytes ('\\0'); double check any IDs you're including with the request.");
522+
throw new Exception\InvalidRequestException("URLs may not contain null bytes ('\\0'); double check any IDs you're including with the request.");
523523
}
524524

525525
$requestStartMs = Util\Util::currentTimeMillis();

tests/Stripe/ApiRequestorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,15 @@ public function testIsDisabled()
729729

730730
public function testRaisesForNullBytesInResourceMethod()
731731
{
732-
$this->expectException(\Stripe\Exception\BadMethodCallException::class);
732+
$this->expectException(\Stripe\Exception\InvalidRequestException::class);
733733
$this->compatExpectExceptionMessageMatches('#null byte#');
734734

735735
Charge::retrieve("abc_123\0");
736736
}
737737

738738
public function testRaisesForNullBytesInRawRequest()
739739
{
740-
$this->expectException(\Stripe\Exception\BadMethodCallException::class);
740+
$this->expectException(\Stripe\Exception\InvalidRequestException::class);
741741
$this->compatExpectExceptionMessageMatches('#null byte#');
742742

743743
$client = new BaseStripeClient([

0 commit comments

Comments
 (0)