Skip to content

Commit

Permalink
avoid xss attack on user picture
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh authored and trasher committed Jun 20, 2019
1 parent 6189eee commit c2aa7a7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions inc/user.class.php
Expand Up @@ -550,6 +550,11 @@ function prepareInputForAdd($input) {
return false;
}

// avoid xss (picture field is autogenerated)
if (isset($input['picture'])) {
$input['picture'] = 'NULL';
}

if (!isset($input["authtype"])) {
$input["authtype"] = Auth::DB_GLPI;
}
Expand Down Expand Up @@ -681,6 +686,11 @@ function post_addItem() {
function prepareInputForUpdate($input) {
global $CFG_GLPI;

// avoid xss (picture field is autogenerated)
if (isset($input['picture'])) {
$input['picture'] = 'NULL';
}

//picture manually uploaded by user
if (isset($input["_blank_picture"]) && $input["_blank_picture"]) {
self::dropPictureFiles($this->fields['picture']);
Expand Down Expand Up @@ -2004,6 +2014,7 @@ function showForm($ID, array $options = []) {
}

if (!empty($this->fields["name"])) {

echo "<td rowspan='4'>" . __('Picture') . "</td>";
echo "<td rowspan='4'>";
echo "<div class='user_picture_border_small' id='picture$rand'>";
Expand Down Expand Up @@ -4853,6 +4864,9 @@ static function checkDefaultPasswords() {
static function getURLForPicture($picture) {
global $CFG_GLPI;

// prevent xss
$picture = Html::cleanInputText($picture);

if (!empty($picture)) {
return $CFG_GLPI["root_doc"]."/front/document.send.php?file=_pictures/$picture";
}
Expand All @@ -4872,6 +4886,9 @@ static function getURLForPicture($picture) {
static function getThumbnailURLForPicture($picture) {
global $CFG_GLPI;

// prevent xss
$picture = Html::cleanInputText($picture);

if (!empty($picture)) {
$tmp = explode(".", $picture);
if (count($tmp) ==2) {
Expand Down

0 comments on commit c2aa7a7

Please sign in to comment.