File tree 2 files changed +17
-1
lines changed
src/Symfony/Component/HttpKernel 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 17
17
18
18
namespace Symfony \Component \HttpKernel \HttpCache ;
19
19
20
+ use Symfony \Component \HttpFoundation \Exception \SuspiciousOperationException ;
20
21
use Symfony \Component \HttpFoundation \Request ;
21
22
use Symfony \Component \HttpFoundation \Response ;
22
23
use Symfony \Component \HttpKernel \HttpKernelInterface ;
@@ -715,7 +716,11 @@ private function getTraceKey(Request $request): string
715
716
$ path .= '? ' .$ qs ;
716
717
}
717
718
718
- return $ request ->getMethod ().' ' .$ path ;
719
+ try {
720
+ return $ request ->getMethod ().' ' .$ path ;
721
+ } catch (SuspiciousOperationException $ e ) {
722
+ return '_BAD_METHOD_ ' .$ path ;
723
+ }
719
724
}
720
725
721
726
/**
Original file line number Diff line number Diff line change @@ -61,6 +61,17 @@ public function testPassesOnNonGetHeadRequests()
61
61
$ this ->assertFalse ($ this ->response ->headers ->has ('Age ' ));
62
62
}
63
63
64
+ public function testPassesSuspiciousMethodRequests ()
65
+ {
66
+ $ this ->setNextResponse (200 );
67
+ $ this ->request ('POST ' , '/ ' , ['HTTP_X-HTTP-Method-Override ' => '__CONSTRUCT ' ]);
68
+ $ this ->assertHttpKernelIsCalled ();
69
+ $ this ->assertResponseOk ();
70
+ $ this ->assertTraceNotContains ('stale ' );
71
+ $ this ->assertTraceNotContains ('invalid ' );
72
+ $ this ->assertFalse ($ this ->response ->headers ->has ('Age ' ));
73
+ }
74
+
64
75
public function testInvalidatesOnPostPutDeleteRequests ()
65
76
{
66
77
foreach (['post ' , 'put ' , 'delete ' ] as $ method ) {
You can’t perform that action at this time.
0 commit comments