*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -504,19 +504,19 @@ $moreforfilter .= '';
$moreforfilter .= '
';
$includeonly = 'hierarchyme';
if (empty($user->rights->user->user->lire)) $includeonly = array($user->id);
-$moreforfilter .= img_picto($langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly');
+$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly');
$moreforfilter .= '
';
if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
{
$moreforfilter .= '';
$moreforfilter .= '';
}
@@ -594,7 +594,7 @@ if (!empty($arrayfields['t.progress']['checked']))
if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").' ';
else print ''.$langs->trans("TimeSpentByUser").' ';*/
print ''.$langs->trans("TimeSpent").''.$langs->trans("Everybody").' ';
-print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
+print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ' '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
print ''.$langs->trans("HourStart").'';
// By default, we can edit only tasks we are assigned to
diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php
index 9a95f8abf79..626634b13cd 100644
--- a/htdocs/projet/activity/permonth.php
+++ b/htdocs/projet/activity/permonth.php
@@ -429,19 +429,19 @@ $moreforfilter .= '';
$moreforfilter .= '
';
$includeonly = 'hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly = array($user->id);
-$moreforfilter .= img_picto($langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
+$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter .= '
';
if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
{
$moreforfilter .= '';
$moreforfilter .= '';
}
@@ -488,7 +488,7 @@ print ' '.$langs->trans("ProgressDeclared").
if ($usertoprocess->id == $user->id) print ' '.$langs->trans("TimeSpentByYou").' ';
else print ''.$langs->trans("TimeSpentByUser").' ';*/
print ''.$langs->trans("TimeSpent").''.$langs->trans("Everybody").' ';
-print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
+print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ' '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
foreach ($TWeek as $week_number)
{
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index c29486302af..f001a73d0f4 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -3,7 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2010 Regis Houssin
* Copyright (C) 2010 François Legastelois
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -559,19 +559,19 @@ $moreforfilter .= '';
$moreforfilter .= '
';
$includeonly = 'hierarchyme';
if (empty($user->rights->user->user->lire)) $includeonly = array($user->id);
-$moreforfilter .= img_picto($langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
+$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter .= '
';
if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
{
$moreforfilter .= '';
$moreforfilter .= '';
}
@@ -652,7 +652,7 @@ if (!empty($arrayfields['t.progress']['checked']))
if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").' ';
else print ''.$langs->trans("TimeSpentByUser").' ';*/
print ''.$langs->trans("TimeSpent").''.$langs->trans("Everybody").' ';
-print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
+print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? ' '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).' ' : '').' ';
for ($idw = 0; $idw < 7; $idw++)
{
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index 33875fb67da..d3991d06c0c 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -436,9 +436,11 @@ if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_f
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
-elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+//elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+elseif ($search_sale || (empty($user->rights->societe->client->voir) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+//if (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+if (empty($user->rights->societe->client->voir) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL";
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index eaa1bf8c2e2..c4f862863e1 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -2577,6 +2577,9 @@ img.userphotosmall { /* size for user photo in lists */
img.userphoto[alt="Gravatar avatar"], img.photouserphoto.dropdown-user-image[alt="Gravatar avatar"] {
background: #fff;
}
+form[name="addtime"] img.userphoto {
+ border: 1px solid #444;
+}
.span-icon-user {
background-image: url();
background-repeat: no-repeat;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index f0e4d593f00..a9fbc589a12 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -2568,6 +2568,9 @@ img.userphotosmall { /* size for user photo in lists */
img.userphoto[alt="Gravatar avatar"] {
background: #fff;
}
+form[name="addtime"] img.userphoto {
+ border: 1px solid #444;
+}
.span-icon-user {
background-image: url();
background-repeat: no-repeat;
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 1aac46933f2..8f8f8c67ca8 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -2398,53 +2398,54 @@ class User extends CommonObject
$label .= '';
$label .= img_picto('', $this->picto).' '.$langs->trans("User").' ';
$label .= ' '.$this->getLibStatut(4);
- $label .= ''.$langs->trans('Name').': '.$this->getFullName($langs, '');
+ $label .= ''.$langs->trans('Name').': '.dol_string_nohtmltag($this->getFullName($langs, ''));
if (!empty($this->login)) {
- $label .= ''.$langs->trans('Login').': '.$this->login;
+ $label .= ''.$langs->trans('Login').': '.dol_string_nohtmltag($this->login);
}
if (!empty($this->job)) {
- $label .= ''.$langs->trans("Job").': '.$this->job;
+ $label .= ''.$langs->trans("Job").': '.dol_string_nohtmltag($this->job);
}
- $label .= ''.$langs->trans("Email").': '.$this->email;
+ $label .= ''.$langs->trans("Email").': '.dol_string_nohtmltag($this->email);
if (!empty($this->phone)) {
- $label .= ''.$langs->trans("Phone").': '.$this->phone;
+ $label .= ''.$langs->trans("Phone").': '.dol_string_nohtmltag($this->phone);
}
if (!empty($this->admin)) {
$label .= ''.$langs->trans("Administrator").' : '.yn($this->admin);
}
+ $company = '';
if (!empty($this->socid)) { // Add thirdparty for external users
$thirdpartystatic = new Societe($db);
$thirdpartystatic->fetch($this->socid);
if (empty($hidethirdpartylogo)) {
$companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
}
- $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
+ $company = ' ('.$langs->trans("Company").': '.dol_string_nohtmltag($thirdpartystatic->name).')';
}
$type = ($this->socid ? $langs->trans("External").$company : $langs->trans("Internal"));
- $label .= ''.$langs->trans("Type").': '.$type;
+ $label .= ''.$langs->trans("Type").': '.dol_string_nohtmltag($type);
$label .= '
';
if ($infologin > 0) {
$label .= ' ';
$label .= ''.$langs->trans("Session").' ';
- $label .= ''.$langs->trans("IPAddress").' : '.$_SERVER["REMOTE_ADDR"];
+ $label .= ''.$langs->trans("IPAddress").' : '.dol_string_nohtmltag(getUserRemoteIP());
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) {
- $label .= ''.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$this->entity.')';
+ $label .= ''.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (User entity '.$this->entity.')';
}
- $label .= ''.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)');
+ $label .= ''.$langs->trans("AuthenticationMode").': '.dol_string_nohtmltag($_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'));
$label .= ''.$langs->trans("ConnectedSince").': '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
$label .= ''.$langs->trans("PreviousConnexion").': '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
- $label .= ''.$langs->trans("CurrentTheme").': '.$conf->theme;
- $label .= ''.$langs->trans("CurrentMenuManager").': '.$menumanager->name;
+ $label .= ''.$langs->trans("CurrentTheme").': '.dol_string_nohtmltag($conf->theme);
+ $label .= ''.$langs->trans("CurrentMenuManager").': '.dol_string_nohtmltag($menumanager->name);
$s = picto_from_langcode($langs->getDefaultLang());
- $label .= ''.$langs->trans("CurrentUserLanguage").': '.($s ? $s.' ' : '').$langs->getDefaultLang();
- $label .= ''.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')';
- $label .= ''.$langs->trans("Layout").': '.$conf->browser->layout;
- $label .= ''.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
+ $label .= ''.$langs->trans("CurrentUserLanguage").': '.dol_string_nohtmltag(($s ? $s.' ' : '').$langs->getDefaultLang());
+ $label .= ''.$langs->trans("Browser").': '.dol_string_nohtmltag($conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')');
+ $label .= ''.$langs->trans("Layout").': '.dol_string_nohtmltag($conf->browser->layout);
+ $label .= ''.$langs->trans("Screen").': '.dol_string_nohtmltag($_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']);
if ($conf->browser->layout == 'phone') {
$label .= ''.$langs->trans("Phone").': '.$langs->trans("Yes");
}
if (!empty($_SESSION["disablemodules"])) {
- $label .= ''.$langs->trans("DisabledModules").': '.join(', ', explode(',', $_SESSION["disablemodules"]));
+ $label .= ''.$langs->trans("DisabledModules").': '.dol_string_nohtmltag(join(', ', explode(',', $_SESSION["disablemodules"])));
}
}
if ($infologin < 0) {
@@ -2508,12 +2509,12 @@ class User extends CommonObject
}
if ($withpictoimg > -2 && $withpictoimg != 2) {
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
- $result .= '';
+ $result .= '';
}
if ($mode == 'login') {
- $result .= dol_trunc($this->login, $maxlen);
+ $result .= dol_string_nohtmltag(dol_trunc($this->login, $maxlen));
} else {
- $result .= $this->getFullName($langs, '', ($mode == 'firstelselast' ? 3 : ($mode == 'firstname' ? 2 : -1)), $maxlen);
+ $result .= dol_string_nohtmltag($this->getFullName($langs, '', ($mode == 'firstelselast' ? 3 : ($mode == 'firstname' ? 2 : -1)), $maxlen));
}
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$result .= ' ';
diff --git a/htdocs/user/home.php b/htdocs/user/home.php
index 4d215685f53..e294be6a219 100644
--- a/htdocs/user/home.php
+++ b/htdocs/user/home.php
@@ -128,7 +128,7 @@ if ($resql)
print '';
print ''.$langs->trans("LastUsersCreated", min($num, $max)).' ';
print ''.$langs->trans("FullList").' ';
- print ' ';
+ print ''."\n";
$i = 0;
while ($i < $num && $i < $max)
diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php
index 8709c66f15d..fb9dbe5100e 100644
--- a/test/phpunit/SecurityTest.php
+++ b/test/phpunit/SecurityTest.php
@@ -186,7 +186,11 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices';
$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
- $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject 1a');
+ $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0a');
+
+ $test = 'This is a < inside string with < and > also and tag like before the >';
+ $result=testSqlAndScriptInject($test, 0);
+ $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b');
// Should detect XSS
$expectedresult=1;
@@ -275,6 +279,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$test="onerror=alert(1)";
$result=testSqlAndScriptInject($test, 0);
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj');
+
+ $test=" rror=alert(document.location)";
+ $result=testSqlAndScriptInject($test, 0);
+ $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk');
}
/**
@@ -299,7 +307,9 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$_GET["param5"]="a_1-b";
$_POST["param6"]="">def';
- $_POST["param8"]="Hackerid < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
$_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
$_POST["param11"]=' Name ';
@@ -363,10 +373,18 @@ class SecurityTest extends PHPUnit\Framework\TestCase
print __METHOD__." result=".$result."\n";
$this->assertEquals('"c:\this is a path~1\aaan" abcdef', $result);
- // With alphanohtml, we must convert the html entities like n
- $result=GETPOST("param8", 'alphanohtml');
+ // With alphanohtml, we must convert the html entities like n and disable all entities
+ $result=GETPOST("param8a", 'alphanohtml');
print __METHOD__." result=".$result."\n";
- $this->assertEquals("HackerassertEquals("Hackersvg onload='console.log(123)'", $result);
+
+ $result=GETPOST("param8b", 'alphanohtml');
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml');
+
+ $result=GETPOST("param8c", 'alphanohtml');
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml');
$result=GETPOST("param9", 'alphanohtml');
print __METHOD__." result=".$result."\n";
@@ -574,10 +592,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because localtest.me is not an external URL
/*$url = 'localtest.me';
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
- print __METHOD__." url=".$url."\n";
- $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL
- */
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
+ print __METHOD__." url=".$url."\n";
+ $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL
+ */
return 0;
}