Skip to content

Commit bff7b93

Browse files
committed
code formatting
1 parent 9180953 commit bff7b93

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

src/Cleaner.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
namespace MasterRO\LaravelXSSFilter;
66

7+
use Illuminate\Support\Arr;
8+
9+
/**
10+
* Class Cleaner
11+
*
12+
* @package MasterRO\LaravelXSSFilter
13+
*/
714
class Cleaner
815
{
916
/**
@@ -42,7 +49,7 @@ protected function escapeScriptsAndIframes(string $value): string
4249
{
4350
preg_match_all($this->scriptsAndIframesPattern, $value, $matches);
4451

45-
foreach (array_get($matches, '0', []) as $script) {
52+
foreach (Arr::get($matches, '0', []) as $script) {
4653
$value = str_replace($script, e($script), $value);
4754
}
4855

@@ -60,6 +67,6 @@ protected function removeInlineEventListeners(string $value): string
6067
{
6168
$string = preg_replace($this->inlineListenersPattern, '', $value);
6269

63-
return !is_string($string) ? '' : $string;
70+
return ! is_string($string) ? '' : $string;
6471
}
6572
}

src/FilterXSS.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
88

9+
/**
10+
* Class FilterXSS
11+
*
12+
* @package MasterRO\LaravelXSSFilter
13+
*/
914
class FilterXSS extends TransformsRequest
1015
{
1116
/**
@@ -34,8 +39,8 @@ public function __construct(Cleaner $cleaner)
3439
/**
3540
* Transform the given value.
3641
*
37-
* @param string $key
38-
* @param mixed $value
42+
* @param string $key
43+
* @param mixed $value
3944
*
4045
* @return string|mixed
4146
*/

src/XSSFilterServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public function boot()
2121
], 'config');
2222
}
2323

24-
2524
/**
2625
* Register the service provider.
2726
*

tests/FilterXSSTest.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@
99
use Orchestra\Testbench\TestCase;
1010
use MasterRO\LaravelXSSFilter\FilterXSS;
1111

12+
/**
13+
* Class FilterXSSTest
14+
*
15+
* @package MasterRO\LaravelXSSFilter\Tests
16+
*/
1217
class FilterXSSTest extends TestCase
1318
{
1419
/**
1520
* @var Request
1621
*/
1722
protected $request;
1823

19-
2024
/**
25+
* Request
26+
*
2127
* @param array $data
2228
* @param string $url
2329
*
@@ -30,18 +36,22 @@ protected function request($data = [], $url = 'https://example.test/store')
3036
return $this->request;
3137
}
3238

33-
3439
/**
40+
* Response From Middleware With Input
41+
*
3542
* @param array $input
3643
*
37-
* @return Response
44+
* @return \Symfony\Component\HttpFoundation\Response
45+
* @throws \Exception
3846
*/
3947
protected function responseFromMiddlewareWithInput($input = [])
4048
{
41-
return app(FilterXSS::class)->handle($this->request($input), function () {});
49+
return app(FilterXSS::class)
50+
->handle($this->request($input), function () {
51+
// nothing to do here
52+
});
4253
}
4354

44-
4555
/**
4656
* @test
4757
*/
@@ -52,7 +62,6 @@ public function it_doesnt_change_non_html_inputs()
5262
$this->assertEquals($input, $this->request->all());
5363
}
5464

55-
5665
/**
5766
* @test
5867
*/
@@ -69,7 +78,6 @@ public function it_escapes_script_tags()
6978
], $this->request->all());
7079
}
7180

72-
7381
/**
7482
* @test
7583
*/
@@ -86,7 +94,6 @@ public function it_doesnt_change_non_script_html_inputs()
8694
], $this->request->all());
8795
}
8896

89-
9097
/**
9198
* @test
9299
*/
@@ -107,7 +114,6 @@ public function it_escapes_embed_elements()
107114
], $this->request->all());
108115
}
109116

110-
111117
/**
112118
* @test
113119
*/
@@ -124,7 +130,6 @@ public function it_removes_inline_listeners()
124130
], $this->request->all());
125131
}
126132

127-
128133
/**
129134
* @test
130135
*/
@@ -160,7 +165,8 @@ public function it_clears_nested_inputs()
160165
/**
161166
* @test
162167
*/
163-
public function it_dont_convert_0_to_empty_string() {
168+
public function it_dont_convert_0_to_empty_string()
169+
{
164170
$this->responseFromMiddlewareWithInput($input = ['text' => '0']);
165171

166172
$this->assertEquals($input, $this->request->all());

0 commit comments

Comments
 (0)