File tree Expand file tree Collapse file tree 2 files changed +59
-1
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,16 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
339
339
->children ()
340
340
->scalarNode ('storage_id ' )->defaultValue ('session.storage.native ' )->end ()
341
341
->scalarNode ('handler_id ' )->defaultValue ('session.handler.native_file ' )->end ()
342
- ->scalarNode ('name ' )->end ()
342
+ ->scalarNode ('name ' )
343
+ ->validate ()
344
+ ->ifTrue (function ($ v ) {
345
+ parse_str ($ v , $ parsed );
346
+
347
+ return implode ('& ' , array_keys ($ parsed )) !== (string ) $ v ;
348
+ })
349
+ ->thenInvalid ('Session name %s contains illegal character(s) ' )
350
+ ->end ()
351
+ ->end ()
343
352
->scalarNode ('cookie_lifetime ' )->end ()
344
353
->scalarNode ('cookie_path ' )->end ()
345
354
->scalarNode ('cookie_domain ' )->end ()
Original file line number Diff line number Diff line change @@ -41,6 +41,55 @@ public function testDoNoDuplicateDefaultFormResources()
41
41
$ this ->assertEquals (array ('FrameworkBundle:Form ' ), $ config ['templating ' ]['form ' ]['resources ' ]);
42
42
}
43
43
44
+ /**
45
+ * @dataProvider getTestValidSessionName
46
+ */
47
+ public function testValidSessionName ($ sessionName )
48
+ {
49
+ $ processor = new Processor ();
50
+ $ config = $ processor ->processConfiguration (
51
+ new Configuration (true ),
52
+ array (array ('session ' => array ('name ' => $ sessionName )))
53
+ );
54
+
55
+ $ this ->assertEquals ($ sessionName , $ config ['session ' ]['name ' ]);
56
+ }
57
+
58
+ public function getTestValidSessionName ()
59
+ {
60
+ return array (
61
+ array (null ),
62
+ array ('PHPSESSID ' ),
63
+ array ('a&b ' ),
64
+ array (',_-!@#$%^*(){}:<>/? ' ),
65
+ );
66
+ }
67
+
68
+ /**
69
+ * @dataProvider getTestInvalidSessionName
70
+ * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
71
+ */
72
+ public function testInvalidSessionName ($ sessionName )
73
+ {
74
+ $ processor = new Processor ();
75
+ $ processor ->processConfiguration (
76
+ new Configuration (true ),
77
+ array (array ('session ' => array ('name ' => $ sessionName )))
78
+ );
79
+ }
80
+
81
+ public function getTestInvalidSessionName ()
82
+ {
83
+ return array (
84
+ array ('a.b ' ),
85
+ array ('a[ ' ),
86
+ array ('a[] ' ),
87
+ array ('a[b] ' ),
88
+ array ('a=b ' ),
89
+ array ('a+b ' ),
90
+ );
91
+ }
92
+
44
93
/**
45
94
* @dataProvider getTestValidTrustedProxiesData
46
95
*/
You can’t perform that action at this time.
0 commit comments