File tree 3 files changed +18
-5
lines changed
3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 41
41
"php-soap/engine-integration-tests" : " ^1.4" ,
42
42
"phpunit/phpunit" : " ^10.0" ,
43
43
"guzzlehttp/guzzle" : " ^7.5"
44
+ },
45
+ "config" : {
46
+ "allow-plugins" : {
47
+ "php-http/discovery" : true
48
+ }
44
49
}
45
50
}
Original file line number Diff line number Diff line change @@ -11,17 +11,18 @@ final class SoapActionDetector
11
11
{
12
12
public static function detectFromRequest (RequestInterface $ request ): string
13
13
{
14
+ $ normalize = static fn (string $ action ): string => trim ($ action , '" \'' );
14
15
$ header = $ request ->getHeader ('SOAPAction ' );
15
16
if ($ header ) {
16
- return $ header [0 ];
17
+ return $ normalize ( $ header [0 ]) ;
17
18
}
18
19
19
20
$ contentTypes = $ request ->getHeader ('Content-Type ' );
20
21
if ($ contentTypes ) {
21
22
$ contentType = $ contentTypes [0 ];
22
23
foreach (explode ('; ' , $ contentType ) as $ part ) {
23
24
if (strpos ($ part , 'action= ' ) !== false ) {
24
- return trim (explode ('= ' , $ part )[1 ], ' " \'' );
25
+ return $ normalize (explode ('= ' , $ part )[1 ]);
25
26
}
26
27
}
27
28
}
Original file line number Diff line number Diff line change @@ -19,7 +19,14 @@ public function test_it_can_detect_soap_action_from_soap_11__soap_action_header(
19
19
static ::assertSame ('actionhere ' , $ result );
20
20
}
21
21
22
-
22
+ public function test_it_strips_out_additional_quotes_from_header_value ()
23
+ {
24
+ $ request = $ this ->createRequest ()->withAddedHeader ('SoapAction ' , '"actionhere" ' );
25
+ $ result = (new SoapActionDetector ())->detectFromRequest ($ request );
26
+
27
+ static ::assertSame ('actionhere ' , $ result );
28
+ }
29
+
23
30
public function test_it_can_detect_soap_action_from_soap_12_content_type_header_with_double_quote ()
24
31
{
25
32
$ request = $ this ->createRequest ()
@@ -30,7 +37,7 @@ public function test_it_can_detect_soap_action_from_soap_12_content_type_header_
30
37
static ::assertSame ('actionhere ' , $ result );
31
38
}
32
39
33
-
40
+
34
41
public function test_it_can_detect_soap_action_from_soap_12_content_type_header_with_single_quote ()
35
42
{
36
43
$ request = $ this ->createRequest ()
@@ -40,7 +47,7 @@ public function test_it_can_detect_soap_action_from_soap_12_content_type_header_
40
47
static ::assertSame ('actionhere ' , $ result );
41
48
}
42
49
43
-
50
+
44
51
public function test_it_throws_an_http_request_exception_when_no_header_could_be_found ()
45
52
{
46
53
$ this ->expectException (RequestException::class);
You can’t perform that action at this time.
0 commit comments