Skip to content

Commit 8672d96

Browse files
Merge branch '7.1' into 7.2
* 7.1: fix: ignore missing directory in isVendor() [OptionsResolver] Allow Union/Intersection Types in Resolved Closures Issue #58821: [DependencyInjection] Support interfaces in ContainerBuilder::getReflectionClass(). Dynamically fix compatibility with doctrine/data-fixtures v2 [HttpKernel] Ensure HttpCache::getTraceKey() does not throw exception don't call EntityManager::initializeObject() with scalar values make RelayProxyTrait compatible with relay extension 0.9.0 [Validator] review italian translations Update PR template
2 parents cd23537 + c90d12b commit 8672d96

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

HttpCache/HttpCache.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace Symfony\Component\HttpKernel\HttpCache;
1919

20+
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
2021
use Symfony\Component\HttpFoundation\Request;
2122
use Symfony\Component\HttpFoundation\Response;
2223
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -704,7 +705,11 @@ private function getTraceKey(Request $request): string
704705
$path .= '?'.$qs;
705706
}
706707

707-
return $request->getMethod().' '.$path;
708+
try {
709+
return $request->getMethod().' '.$path;
710+
} catch (SuspiciousOperationException) {
711+
return '_BAD_METHOD_ '.$path;
712+
}
708713
}
709714

710715
/**

Tests/HttpCache/HttpCacheTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ public function testPassesOnNonGetHeadRequests()
108108
$this->assertFalse($this->response->headers->has('Age'));
109109
}
110110

111+
public function testPassesSuspiciousMethodRequests()
112+
{
113+
$this->setNextResponse(200);
114+
$this->request('POST', '/', ['HTTP_X-HTTP-Method-Override' => '__CONSTRUCT']);
115+
$this->assertHttpKernelIsCalled();
116+
$this->assertResponseOk();
117+
$this->assertTraceNotContains('stale');
118+
$this->assertTraceNotContains('invalid');
119+
$this->assertFalse($this->response->headers->has('Age'));
120+
}
121+
111122
public function testInvalidatesOnPostPutDeleteRequests()
112123
{
113124
foreach (['post', 'put', 'delete'] as $method) {

0 commit comments

Comments
 (0)