Skip to content

Commit

Permalink
Fixed issue #18985: [security] Reflected XSS (#3309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Jul 31, 2023
1 parent 3e7de51 commit 553f3c4
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions application/controllers/UserManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,20 @@ public function actionRenderUserImport(string $importFormat = 'csv')
['errors' => [gT("You do not have permission to access this page.")], 'noButton' => true]
);
}

$importNote = sprintf(gT("Please make sure that your CSV contains the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$allowFileType = ".csv";

if ($importFormat == 'json') {
$importNote = sprintf(gT("Please make sure that your JSON arrays contain the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$allowFileType = ".json,application/json";
if (!in_array($importFormat, ['csv', 'json'])) {
throw new LSUserException(400, gT("Invalid format"));
}

switch ($importFormat) {
case "json":
$importNote = sprintf(gT("Please make sure that your JSON arrays contain the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$allowFileType = ".json,application/json";
break;
case "csv":
default:
$importNote = sprintf(gT("Please make sure that your CSV contains the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$allowFileType = ".csv";
}
return $this->renderPartial('partial/importuser', [
"note" => $importNote,
"importFormat" => $importFormat,
Expand All @@ -749,7 +754,9 @@ public function actionImportUsers(string $importFormat = 'csv'): string
['errors' => [gT("You do not have permission to access this page.")], 'noButton' => true]
);
}

if (!in_array($importFormat, ['csv', 'json'])) {
throw new LSUserException(400, gT("Invalid format"));
}
$overwriteUsers = boolval(App()->getRequest()->getPost('overwrite'));

switch ($importFormat) {
Expand All @@ -758,7 +765,7 @@ public function actionImportUsers(string $importFormat = 'csv'): string
break;
case "csv":
default:
$aNewUsers = UserParser::getDataFromCSV($_FILES); //importFormat default is csv ...
$aNewUsers = UserParser::getDataFromCSV($_FILES);
}
if (empty($aNewUsers)) {
Yii::app()->setFlashMessage(gT("No user definition found in file."), 'error');
Expand Down

0 comments on commit 553f3c4

Please sign in to comment.