@@ -108,6 +108,62 @@ public function it_should_return_the_token_from_the_alt_authorization_headers()
108108 $ this ->assertTrue ($ parser ->hasToken ());
109109 }
110110
111+ /** @test */
112+ public function it_should_not_strip_trailing_hyphens_from_the_authorization_header ()
113+ {
114+ $ request = Request::create ('foo ' , 'POST ' );
115+ $ request ->headers ->set ('Authorization ' , 'Bearer foobar-- ' );
116+
117+ $ parser = new Parser ($ request );
118+
119+ $ parser ->setChain ([
120+ new QueryString ,
121+ new InputSource ,
122+ new AuthHeaders ,
123+ new RouteParams ,
124+ ]);
125+
126+ $ this ->assertSame ($ parser ->parseToken (), 'foobar-- ' );
127+ $ this ->assertTrue ($ parser ->hasToken ());
128+ }
129+
130+ /**
131+ * @test
132+ * @dataProvider whitespaceProvider
133+ */
134+ public function it_should_handle_excess_whitespace_from_the_authorization_header ($ whitespace )
135+ {
136+ $ request = Request::create ('foo ' , 'POST ' );
137+ $ request ->headers ->set ('Authorization ' , "Bearer {$ whitespace }foobar {$ whitespace }" );
138+
139+ $ parser = new Parser ($ request );
140+
141+ $ parser ->setChain ([
142+ new QueryString ,
143+ new InputSource ,
144+ new AuthHeaders ,
145+ new RouteParams ,
146+ ]);
147+
148+ $ this ->assertSame ($ parser ->parseToken (), 'foobar ' );
149+ $ this ->assertTrue ($ parser ->hasToken ());
150+ }
151+
152+ public function whitespaceProvider ()
153+ {
154+ return [
155+ 'space ' => [' ' ],
156+ 'multiple spaces ' => [' ' ],
157+ 'tab ' => ["\t" ],
158+ 'multiple tabs ' => ["\t\t\t" ],
159+ 'new line ' => ["\n" ],
160+ 'multiple new lines ' => ["\n\n\n" ],
161+ 'carriage return ' => ["\r" ],
162+ 'carriage returns ' => ["\r\r\r" ],
163+ 'mixture of whitespace ' => ["\t \n \r \t \n" ],
164+ ];
165+ }
166+
111167 /** @test */
112168 public function it_should_return_the_token_from_query_string ()
113169 {
0 commit comments