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 @@ -380,7 +380,16 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
380380 ->children ()
381381 ->scalarNode ('storage_id ' )->defaultValue ('session.storage.native ' )->end ()
382382 ->scalarNode ('handler_id ' )->defaultValue ('session.handler.native_file ' )->end ()
383- ->scalarNode ('name ' )->end ()
383+ ->scalarNode ('name ' )
384+ ->validate ()
385+ ->ifTrue (function ($ v ) {
386+ parse_str ($ v , $ parsed );
387+
388+ return implode ('& ' , array_keys ($ parsed )) !== (string ) $ v ;
389+ })
390+ ->thenInvalid ('Session name %s contains illegal character(s) ' )
391+ ->end ()
392+ ->end ()
384393 ->scalarNode ('cookie_lifetime ' )->end ()
385394 ->scalarNode ('cookie_path ' )->end ()
386395 ->scalarNode ('cookie_domain ' )->end ()
Original file line number Diff line number Diff line change @@ -41,6 +41,55 @@ public function testDoNoDuplicateDefaultFormResources()
4141 $ this ->assertEquals (array ('FrameworkBundle:Form ' ), $ config ['templating ' ]['form ' ]['resources ' ]);
4242 }
4343
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+
4493 /**
4594 * @dataProvider getTestValidTrustedProxiesData
4695 */
You can’t perform that action at this time.
0 commit comments