Skip to content

Commit 66eb484

Browse files
committed
Update
- Added : sanitizing user input
1 parent 0366468 commit 66eb484

File tree

16 files changed

+176
-135
lines changed

16 files changed

+176
-135
lines changed

app/Forms/UserProfileForm.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function processAttribute( $request )
5959

6060
foreach( $request->input( 'attribute' ) as $key => $value ) {
6161
if ( in_array( $key, $allowedInputs ) ) {
62-
$user->$key = $value;
62+
$user->$key = preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $value );
6363
}
6464
}
6565

@@ -76,6 +76,9 @@ public function processAttribute( $request )
7676

7777
public function processOptions( $request )
7878
{
79+
/**
80+
* @var UserOptions
81+
*/
7982
$userOptions = app()->make( UserOptions::class );
8083

8184
if ( $request->input( 'options' ) ) {

app/Http/Controllers/Dashboard/CrudController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public function crudPost( String $namespace, CrudPostRequest $request )
114114
$entry->$name = $value;
115115
}
116116
}
117+
118+
/**
119+
* sanitizing input to remove
120+
* all script tags
121+
*/
122+
$entry->$name = preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $entry->$name );
117123
}
118124

119125
/**
@@ -229,6 +235,12 @@ public function crudPut( String $namespace, $id, CrudPutRequest $request )
229235
$entry->$name = $value;
230236
}
231237
}
238+
239+
/**
240+
* sanitizing input to remove
241+
* all script tags
242+
*/
243+
$entry->$name = preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $entry->$name );
232244
}
233245

234246
/**

app/Services/Options.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function set( $key, $value, $expiration = null )
6161
{
6262
$this->hasFound = false;
6363
$storedOption = null;
64-
64+
6565
/**
6666
* if an option has been found,
6767
* it will save the new value and update
@@ -150,6 +150,12 @@ public function set( $key, $value, $expiration = null )
150150

151151
public function beforeSave( $option )
152152
{
153+
/**
154+
* sanitizing input to remove
155+
* all script tags
156+
*/
157+
$option->value = preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $option->value );
158+
153159
return $option;
154160
}
155161

app/Services/SettingsPage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ public function getPlainData( Request $request )
107107
public function saveForm( Request $request )
108108
{
109109
$service = new CrudService;
110+
111+
/**
112+
* @var Options
113+
*/
110114
$options = app()->make( Options::class );
111115

112116
foreach( $service->getPlainData( $this, $request ) as $key => $value ) {

app/Services/UserOptions.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public function option()
2222
public function beforeSave( $option )
2323
{
2424
$option->user_id = $this->user_id;
25+
26+
/**
27+
* sanitizing input to remove
28+
* all script tags
29+
*/
30+
$option->value = preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $option->value );
31+
2532
return $option;
2633
}
2734
}

public/js/app.js

Lines changed: 49 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/auth.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ eval("// removed by extract-text-webpack-plugin//# sourceURL=[module]\n//# sourc
1818
/*! no static exports found */
1919
/***/ (function(module, exports, __webpack_require__) {
2020

21-
__webpack_require__(/*! D:\laragon\www\NexoPOS-4x\resources\ts\bootstrap.ts */"./resources/ts/bootstrap.ts");
22-
module.exports = __webpack_require__(/*! D:\laragon\www\NexoPOS-4x\resources\sass\app.scss */"./resources/sass/app.scss");
21+
__webpack_require__(/*! /var/www/html/NexoPOS-v4/resources/ts/bootstrap.ts */"./resources/ts/bootstrap.ts");
22+
module.exports = __webpack_require__(/*! /var/www/html/NexoPOS-v4/resources/sass/app.scss */"./resources/sass/app.scss");
2323

2424

2525
/***/ })

public/js/dashboard.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)