Merge branch '23.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2026-04-30 14:57:57 +02:00
commit 1172677b01
9 changed files with 46 additions and 17 deletions

View file

@ -31,7 +31,9 @@ The following changes may create regressions for some external modules, but were
***** ChangeLog for 23.0.3 compared to 23.0.2 *****
FIX: IDOR on messaging.php - credit Aksoum Abderrahmane
FIX: Some remaining cross-customer object creation on API (proposal, orders) - credit Mitch311
FIX: Set the default seed key EVENTORGANIZATION_SECUREKEY at module - credit Shunsuke Hashimoto (@futabato)
SEC: Set the default seed key EVENTORGANIZATION_SECUREKEY at module install - credit Shunsuke Hashimoto (@futabato)
SEC: Better sanitization param for GETPOST of htmlheader of website page - See commit bbbbb56c6455514dcd0acca53afc17a92ed21bb9
***** ChangeLog for 23.0.2 compared to 23.0.1 *****

View file

@ -168,7 +168,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
$securitycspstring = "";
if ($sourcetype == "data") {
$forceCSPArr[$directivecsp][] = "data:".$sourcedatacsp;
} elseif ($sourcetype == "input") {
} elseif (isset($sourcetype) && $sourcetype == "blob") {
$forceCSPArr[$directivecsp][] = "blob:".$sourcedatacsp;
} elseif (isset($sourcetype) && $sourcetype == "input") {
if (empty($forceCSPArr[$directivecsp])) {
$forceCSPArr[$directivecsp] = array();
}

View file

@ -527,7 +527,7 @@ class DolEditor
$out .= 'jQuery(document).ready(function() {';
$out .= ' jQuery(".buttonforacesave").click(function() {
console.log("We click on savefile button for component '.dol_escape_js($this->htmlname).'");
console.log("We click on button (with class .buttonforacesave) that must fill ace fields for component '.dol_escape_js($this->htmlname).'");
var aceEditor = window.ace.edit("'.dol_escape_js($this->htmlname).'aceeditorid");
if (aceEditor) {
var cursorPos = aceEditor.getCursorPosition();

View file

@ -1516,6 +1516,7 @@ class FormMail extends Form
* @param string $htmlContent HTML name of WYSIWYG field to fill once layout has been chosen
* @param string $showlinktolayout Show link to layout
* @return string HTML for model email boxes
* @see getContentPageTemplate()
*/
public function getEmailLayoutSelector($htmlContent = 'message', $showlinktolayout = 'email')
{

View file

@ -349,6 +349,7 @@ class FormWebsite
*
* @param string $htmlContent HTML name of WYSIWYG field
* @return string HTML for model page boxes
* @see getEmailLayoutSelector()
*/
public function getContentPageTemplate($htmlContent = 'message')
{
@ -359,8 +360,12 @@ class FormWebsite
require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php';
$listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$');
$arrayofsamples = array();
$arrayofsamples['empty'] = 'EmptyPage'; // Always this one first
// Define list of layouts to use
$arrayofsamples = array(
'empty' => 'EmptyPage',
);
foreach ($listofsamples as $sample) {
$reg = array();
if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg)) {
@ -391,7 +396,7 @@ class FormWebsite
$contentHtml = file_exists($pathtoTemplateFile) ? make_substitutions(@file_get_contents($pathtoTemplateFile), $substitutionarray) : '';
$out .= '<div class="template-option" data-template="'.$template.'" data-content="'.htmlentities($contentHtml).'">';
$out .= '<img class="maillayout" alt="'.$template.'" src="'.DOL_URL_ROOT.'/theme/common/maillayout/'.$template.'.png" />';
$out .= '<img class="maillayout" alt="'.$template.'" src="'.DOL_URL_ROOT.'/theme/common/maillayout/'.($template === 'empty' ? 'none' : $template).'.png" />';
$out .= '<span class="template-option-text">'.($template != 'text' ? ucfirst($template) : ucfirst($templateFunction)).'</span>';
$out .= '</div>';
}

View file

@ -2245,6 +2245,7 @@ function GetContentPolicySources()
// Fetch directives
"fetch" => array(
"*" => array("label" => "*", "data-sourcetype" => "select"),
"blob" => array("label" => "blob:", "data-sourcetype" => "blob"),
"data" => array("label" => "data:", "data-sourcetype" => "data"),
"self" => array("label" => "self", "data-sourcetype" => "quoted"),
"unsafe-eval" => array("label" => "unsafe-eval", "data-sourcetype" => "quoted"),

View file

@ -625,12 +625,12 @@ if ($conf->use_javascript_ajax) {
}
print '</td></tr>';
if (getDolGlobalInt('STRIPE_AUTO_RECORD_PAYOUT')) {
print '<tr class="oddeven"><td>';
print $langs->trans("StripeUserAccountForActions").'</td><td>';
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'), 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("StripeUserAccountForActions").'</td><td>';
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'), 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
print '</td></tr>';
if (getDolGlobalInt('STRIPE_AUTO_RECORD_PAYOUT')) {
print '<tr class="oddeven"><td>';
print $langs->trans("BankAccountForBankTransfer").'</td><td>';
print img_picto('', 'bank_account', 'class="pictofixedwidth"');

View file

@ -279,13 +279,28 @@ class WebsitePage extends CommonObject
// Remove spaces and be sure we have main language only
$this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
// Check there is no PHP into HTML header
$dataposted = trim($this->htmlheader); // Must accept tags like '<script>' and '<link>'
$dataposted = preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), $dataposted);
$dataposted = str_replace('<?=', '<?php', $dataposted);
// Test if page contains dynamic PHP content
if (!$user->hasRight('website', 'writephp')) {
// Check there is no PHP content into the imported file (must be only HTML + JS)
$phpcontent = dolKeepOnlyPhpCode($this->content);
if ($phpcontent) {
$this->error = 'Error: you try to create a page with PHP content without having permissions for that.';
$this->error = 'Error: you try to create a page with PHP content in HTML body without having permissions for that.';
$this->errors[] = $this->error;
return -1;
}
// Check there is no PHP content into the imported file (must be only HTML + JS)
// Note: This one may be uselss because this->htmlheader should be retrieved now using GETPOST(..., 'restricthtmlallowlinkscript') so without PHP content. We keep it in case of.
$phpcontent = dolKeepOnlyPhpCode($this->htmlheader);
if ($phpcontent) {
$this->error = 'Error: you try to create a page with PHP content in HTML header without having permissions for that.';
$this->errors[] = $this->error;
return -1;
}

View file

@ -1179,7 +1179,8 @@ if ($action == 'addcontainer' && $usercanedit) {
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09') ? 1 : 0;
$objectpage->htmlheader = GETPOST('htmlheader', 'none'); // Must accept tags like '<script>' and '<link>'
$objectpage->htmlheader = GETPOST('htmlheader', 'restricthtmlallowlinkscript'); // Must accept tags like '<script>' and '<link>'
$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml');
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS');
$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID');
@ -1642,7 +1643,7 @@ if ($action == 'updatecss' && $usercanedit) {
if (!$errorphpcheck) {
$htmlheadercontent = '';
/* We disable php code since htmlheader is never executed as an include but only read by fgets_content.
/* We disable php code since global htmlheader for all website is never executed as an include but only read by fgets_content.
$htmlheadercontent.= "<?php // BEGIN PHP\n";
$htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n";
$htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n";
@ -4812,7 +4813,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) {
$pageallowedinframes = 1;
}
if (GETPOST('htmlheader', 'none')) { // Must accept tags like '<script>' and '<link>'
if (GETPOST('htmlheader', 'restricthtmlallowlinkscript')) { // Must accept tags like '<script>' and '<link>'
$pagehtmlheader = GETPOST('htmlheader', 'none');
}
@ -5164,6 +5165,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
print '<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).'" placeholder="'.dol_escape_htmltag($langs->trans("Anonymous")).'">';
print '</td></tr>';
// Web page header
print '<tr><td class="tdhtmlheader tdtop">';
$htmlhelp = $langs->trans("EditTheWebSiteForACommonHeader").'<br><br>';
$htmlhelp .= $langs->trans("Examples").' :<br>';
@ -5173,7 +5175,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
print $form->textwithpicto($langs->transnoentitiesnoconv('HtmlHeaderPage'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
print '</td><td>';
$poscursor = array('x' => GETPOST('htmlheader_x'), 'y' => GETPOST('htmlheader_y'));
$doleditor = new DolEditor('htmlheader', $pagehtmlheader, '', 120, 'ace', 'In', true, false, 'ace', ROWS_3, '100%', 0, $poscursor);
$doleditor = new DolEditor('htmlheader', $pagehtmlheader, '', 160, 'ace', 'In', true, false, 'ace', ROWS_4, '100%', 0, $poscursor);
print $doleditor->Create(1, '', true, 'HTML Header', 'html');
print '</td></tr>';
@ -5188,12 +5190,13 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
print '</table>';
if ($action == 'createcontainer') {
$langs->load("website");
print '<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">';
print '<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans("Create").'">';
print '<input type="submit" class="button small buttonforacesave" name="addcontainer" value="'.$langs->trans("Create").'">';
print '<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans("Cancel").'">';
print '</div>';