Skip to content

Commit

Permalink
Merge upstream and update generated code for v1471
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe-openapi[bot] committed Feb 7, 2025
2 parents 396f47a + 931c31f commit fcf1d1c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1467
v1471
6 changes: 6 additions & 0 deletions lib/ApiRequestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ private function _requestRaw($method, $url, $params, $headers, $apiMode, $usage)
{
list($absUrl, $rawHeaders, $params, $hasFile, $myApiKey) = $this->_prepareRequest($method, $url, $params, $headers, $apiMode);

// for some reason, PHP users will sometimes include null bytes in their paths, which leads to cryptic server 400s.
// we'll be louder about this to help catch issues earlier.
if (false !== \strpos($absUrl, "\0") || false !== \strpos($absUrl, '%00')) {
throw new Exception\InvalidRequestException("URLs may not contain null bytes ('\\0'); double check any IDs you're including with the request.");
}

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

list($rbody, $rcode, $rheaders) = self::httpClient()->request(
Expand Down
19 changes: 19 additions & 0 deletions tests/Stripe/ApiRequestorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,23 @@ public function testIsDisabled()
$result = $method->invoke(null, 'procopen, php_uname, exec', 'php_uname');
static::assertTrue($result);
}

public function testRaisesForNullBytesInResourceMethod()
{
$this->expectException(\Stripe\Exception\InvalidRequestException::class);
$this->compatExpectExceptionMessageMatches('#null byte#');

Charge::retrieve("abc_123\0");
}

public function testRaisesForNullBytesInRawRequest()
{
$this->expectException(\Stripe\Exception\InvalidRequestException::class);
$this->compatExpectExceptionMessageMatches('#null byte#');

$client = new BaseStripeClient([
'api_key' => 'sk_test_client',
]);
$client->rawRequest('get', "/v1/xyz\0");
}
}

0 comments on commit fcf1d1c

Please sign in to comment.