Skip to content

Commit

Permalink
Merge branch 'develop' into dev_new_default_email_template_ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Dec 24, 2024
2 parents 901b9da + 0a005ed commit d7c7391
Show file tree
Hide file tree
Showing 38 changed files with 373 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Definition:

As the Developer:

1. Check you agree with the terms of the [DCO - Developer's Certificate of Origin](https://github.com/Dolibarr/dolibarr/DCO)
1. Check you agree with the terms of the [DCO - Developer's Certificate of Origin](https://github.com/Dolibarr/dolibarr/blob/develop/DCO)
2. [Fork](https://help.github.com/articles/fork-a-repo) the [GitHub repository](https://github.com/Dolibarr/dolibarr).
3. Clone your fork.
4. Choose a branch(See the [Branches](#branches) section below).
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ repos:
exclude: |
(?x)^(htdocs/includes/.*)$
# This checks that yaml files are correct
args: [--branch, develop, --pattern, \d+.0$]
- id: check-yaml
args: [--unsafe]
# This checks that json files are correct
Expand Down
66 changes: 0 additions & 66 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16908,18 +16908,6 @@ parameters:
count: 1
path: ../../htdocs/core/tpl/objectline_view.tpl.php

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/core/tpl/objectline_view.tpl.php

-
message: '#^Variable \$i might not be defined\.$#'
identifier: variable.undefined
count: 5
path: ../../htdocs/core/tpl/objectline_view.tpl.php

-
message: '#^Variable \$objp might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -24864,18 +24852,6 @@ parameters:
count: 1
path: ../../htdocs/product/canvas/product/actions_card_product.class.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/product/canvas/product/tpl/card_create.tpl.php

-
message: '#^Variable \$refalreadyexists might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/product/canvas/product/tpl/card_create.tpl.php

-
message: '#^Property ActionsCardService\:\:\$field_list has no type specified\.$#'
identifier: missingType.property
Expand All @@ -24888,30 +24864,6 @@ parameters:
count: 1
path: ../../htdocs/product/canvas/service/actions_card_service.class.php

-
message: '#^Cannot access property \$control on mixed\.$#'
identifier: property.nonObject
count: 2
path: ../../htdocs/product/canvas/service/tpl/card_create.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/product/canvas/service/tpl/card_create.tpl.php

-
message: '#^Variable \$refalreadyexists might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/product/canvas/service/tpl/card_create.tpl.php

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/product/canvas/service/tpl/card_create.tpl.php

-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
Expand Down Expand Up @@ -30450,24 +30402,6 @@ parameters:
count: 3
path: ../../htdocs/societe/canvas/company/tpl/card_view.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/individual/tpl/card_create.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/individual/tpl/card_edit.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/societe/canvas/individual/tpl/card_view.tpl.php

-
message: '#^Variable \$objcanvas might not be defined\.$#'
identifier: variable.undefined
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ function initfieldrequired() {

// EMail
print '<tr><td>'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '</span>' : '').'</td>';
print '<td>'.img_picto('', 'object_email', 'class="pictofixedwidth"').'<input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET("member_email") ? GETPOST("member_email", '', 2) : $object->email).'"></td></tr>';
print '<td>'.img_picto('', 'object_email', 'class="pictofixedwidth"').'<input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET("member_email") ? GETPOST("member_email", 'alphanohtml', 2) : $object->email).'"></td></tr>';

// Website
print '<tr><td>'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).'</td>';
Expand Down
6 changes: 2 additions & 4 deletions htdocs/admin/dict.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2011-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
Expand Down Expand Up @@ -723,10 +723,8 @@
'supplier_proposal' => img_picto('', 'supplier_proposal', 'class="pictofixedwidth"').$langs->trans('SupplierProposal'),
'order_supplier' => img_picto('', 'supplier_order', 'class="pictofixedwidth"').$langs->trans('SupplierOrder'),
'invoice_supplier' => img_picto('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans('SupplierBill'),
'conferenceorbooth' => img_picto('', 'eventorganization', 'class="pictofixedwidth"').$langs->trans('ConferenceOrBooth'),
);
if (getDolGlobalString('MAIN_FEATURES_LEVEL') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$elementList['conferenceorbooth'] = img_picto('', 'eventorganization', 'class="pictofixedwidth"').$langs->trans('ConferenceOrBooth');
}

complete_elementList_with_modules($elementList);

Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5128,7 +5128,7 @@ public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0,
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) {
if ($showempty) {
$return .= '<option value="none"></option>';
$return .= '<option value="-1"></option>';
}

while ($res = $this->db->fetch_object($resql)) {
Expand All @@ -5144,6 +5144,8 @@ public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0,
}
}
$return .= '</select>';

$return .= ajax_combobox($htmlname);
}
return $return;
}
Expand Down
32 changes: 23 additions & 9 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,7 @@ function dol_get_object_properties($obj, $properties = [])
* @param T $object Object to clone
* @param int $native 0=Full isolation method, 1=Native PHP method, 2=Full isolation method keeping only scalar and array properties (recommended)
* @return T Clone object
*
* @see https://php.net/manual/language.oop5.cloning.php
* @phan-suppress PhanTypeExpectedObjectPropAccess
*/
Expand Down Expand Up @@ -10523,7 +10524,7 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
* @param int<0,1> $hideerrors 1=Hide errors
* @param string $onlysimplestring '0' (deprecated, do not use it anymore)=Accept all chars,
* '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';',
* '2' (used for example for the compute property of extrafields)=Accept also '[]'
* '2' (used for example for the compute property of extrafields)=Accept also '<[]'
* @return void|string Nothing or return result of eval (even if type can be int, it is safer to assume string and find all potential typing issues as abs(dol_eval(...)).
* @see verifCond(), checkPHPCode() to see sanitizing rules that should be very close.
* @phan-suppress PhanPluginUnsafeEval
Expand Down Expand Up @@ -10551,21 +10552,31 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
if ($onlysimplestring == '1' || $onlysimplestring == '2') {
// We must accept with 1: '1 && getDolGlobalInt("doesnotexist1") && getDolGlobalString("MAIN_FEATURES_LEVEL")'
// We must accept with 1: '$user->hasRight("cabinetmed", "read") && !$object->canvas=="patient@cabinetmed"'
// We must accept with 2: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"
// We must accept with 2: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) <= 99) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"

// Check if there is dynamic call (first we check chars are all into use a whitelist chars)
// Check if there is dynamic call (first we check chars are all into a whitelist chars)
$specialcharsallowed = '^$_+-.*>&|=!?():"\',/@';
if ($onlysimplestring == '2') {
$specialcharsallowed .= '[]';
$specialcharsallowed .= '<[]';
}
if (getDolGlobalString('MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL')) {
$specialcharsallowed .= getDolGlobalString('MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
}
if (preg_match('/[^a-z0-9\s'.preg_quote($specialcharsallowed, '/').']/i', $s)) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s;
return 'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s;
} else {
dol_syslog('Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s, LOG_WARNING);
return '';
}
}

// Check if there is a < or <= without spaces before/after
if (preg_match('/<=?[^\s]/', $s)) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (mode '.$onlysimplestring.', found a < or <= without space before and after): '.$s;
} else {
dol_syslog('Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s, LOG_WARNING);
dol_syslog('Bad string syntax to evaluate (mode '.$onlysimplestring.', found a < or <= without space before and after): '.$s, LOG_WARNING);
return '';
}
}
Expand All @@ -10580,15 +10591,17 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
}
}

// Now we check if we try dynamic call (by removing white list pattern of using parenthesis then testing if a parenthesis exists)
// Now we check if we try dynamic call
// First we remove white list pattern of using parenthesis then testing if one open parenthesis exists
$savescheck = '';
$scheck = $s;
while ($scheck && $savescheck != $scheck) {
$savescheck = $scheck;
$scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $scheck); // accept parenthesis in '...->method(...'
$scheck = preg_replace('/::[a-zA-Z0-9_]+\(/', '->__METHOD__', $scheck); // accept parenthesis in '...::method(...'
$scheck = preg_replace('/^\(/', '__PARENTHESIS__ ', $scheck); // accept parenthesis in '(...'. Must replace with __PARENTHESIS__ with a space after to allow following substitutions
$scheck = preg_replace('/\s\(/', '__PARENTHESIS__ ', $scheck); // accept parenthesis in '... (' like in 'if ($a == 1)'. Must replace with __PARENTHESIS__ with a space after to allow following substitutions
$scheck = preg_replace('/^\(+/', '__PARENTHESIS__ ', $scheck); // accept parenthesis in '(...'. Must replace with "__PARENTHESIS__ with a space after "to allow following substitutions
$scheck = preg_replace('/\&\&\s+\(/', '__ANDPARENTHESIS__ ', $scheck); // accept parenthesis in '... (' like in '&& (...'. Must replace with "__PARENTHESIS__ with a space after" to allow following substitutions
$scheck = preg_replace('/\|\|\s+\(/', '__ORPARENTHESIS__ ', $scheck); // accept parenthesis in '... (' like in '|| (...'. Must replace with "__PARENTHESIS__ with a space after" to allow following substitutions
$scheck = preg_replace('/^!?[a-zA-Z0-9_]+\(/', '__FUNCTION__', $scheck); // accept parenthesis in 'function(' and '!function('
$scheck = preg_replace('/\s!?[a-zA-Z0-9_]+\(/', '__FUNCTION__', $scheck); // accept parenthesis in '... function(' and '... !function('
$scheck = preg_replace('/^!\(/', '__NOTANDPARENTHESIS__', $scheck); // accept parenthesis in '!('
Expand All @@ -10597,6 +10610,7 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
}
//print 'scheck='.$scheck." : ".strpos($scheck, '(')."<br>\n";

// Now test if it remains 1 one parenthesis.
if (strpos($scheck, '(') !== false) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (mode '.$onlysimplestring.', found call of a function or method without using the direct name of the function): '.$s;
Expand Down
Loading

0 comments on commit d7c7391

Please sign in to comment.