File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,17 +116,26 @@ public function testBeforeInvalidUTF8StringInArrayKeyCausesException(): void
116116 $ this ->invalidChars ->before ($ this ->request );
117117 }
118118
119- public function testBeforeInvalidControlCharCausesException (): void
119+ #[DataProvider('provideBeforeInvalidControlCharCausesException ' )]
120+ public function testBeforeInvalidControlCharCausesException (string $ invalidString ): void
120121 {
121122 $ this ->expectException (SecurityException::class);
122123 $ this ->expectExceptionMessage ('Invalid Control characters in cookie: ' );
123124
124- $ stringWithNullChar = "String contains null char and line break. \0\n" ;
125- service ('superglobals ' )->setCookie ('val ' , $ stringWithNullChar );
125+ service ('superglobals ' )->setCookie ('val ' , $ invalidString );
126126
127127 $ this ->invalidChars ->before ($ this ->request );
128128 }
129129
130+ public static function provideBeforeInvalidControlCharCausesException (): iterable
131+ {
132+ yield 'null byte ' => ["String with null char \0" ];
133+
134+ yield 'backspace ' => ["String with backspace \x08" ];
135+
136+ yield 'escape ' => ["String with escape \x1b" ];
137+ }
138+
130139 public function testBeforeInvalidControlCharInArrayKeyCausesException (): void
131140 {
132141 $ this ->expectException (SecurityException::class);
You can’t perform that action at this time.
0 commit comments