Skip to content

Commit 8a10e3f

Browse files
allowingrfvjyy
andauthored
trim zwnbsp (#41949)
* trim zwnbsp * fix zwnbsp Co-authored-by: j <[email protected]>
1 parent d6822c4 commit 8a10e3f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Illuminate/Foundation/Http/Middleware/TrimStrings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function transform($key, $value)
5353
return $value;
5454
}
5555

56-
return is_string($value) ? preg_replace('~^\s+|\s+$~iu', '', $value) : $value;
56+
return is_string($value) ? preg_replace('~^[\s]+|[\s]+$~iu', '', $value) : $value;
5757
}
5858

5959
/**

tests/Foundation/Http/Middleware/TrimStringsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function testTrimStringsNBSP()
3434
$middleware = new TrimStrings;
3535
$symfonyRequest = new SymfonyRequest([
3636
// Here has some NBSP, but it still display to space.
37+
// Please note, do not edit in browser
3738
'abc' => '  123   ',
39+
'zwnbsp' => ' ha ',
3840
'xyz' => '',
3941
'foo' => '',
4042
'bar' => '  だ   ',
@@ -45,6 +47,7 @@ public function testTrimStringsNBSP()
4547

4648
$middleware->handle($request, function (Request $request) {
4749
$this->assertSame('123', $request->get('abc'));
50+
$this->assertSame('ha', $request->get('zwnbsp'));
4851
$this->assertSame('', $request->get('xyz'));
4952
$this->assertSame('', $request->get('foo'));
5053
$this->assertSame('', $request->get('bar'));

0 commit comments

Comments
 (0)