File tree 2 files changed +17
-1
lines changed 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 ;
@@ -705,7 +706,11 @@ private function getTraceKey(Request $request): string
705
706
$ path .= '? ' .$ qs ;
706
707
}
707
708
708
- return $ request ->getMethod ().' ' .$ path ;
709
+ try {
710
+ return $ request ->getMethod ().' ' .$ path ;
711
+ } catch (SuspiciousOperationException ) {
712
+ return '_BAD_METHOD_ ' .$ path ;
713
+ }
709
714
}
710
715
711
716
/**
Original file line number Diff line number Diff line change @@ -108,6 +108,17 @@ public function testPassesOnNonGetHeadRequests()
108
108
$ this ->assertFalse ($ this ->response ->headers ->has ('Age ' ));
109
109
}
110
110
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
+
111
122
public function testInvalidatesOnPostPutDeleteRequests ()
112
123
{
113
124
foreach (['post ' , 'put ' , 'delete ' ] as $ method ) {
You can’t perform that action at this time.
0 commit comments