Fix #huntr88841fe0-e332-49ce-a46b-36d4f091fd89

This commit is contained in:
Laurent Destailleur
2023-02-13 13:29:30 +01:00
parent 9e79e00f10
commit 4a49ca86c9
3 changed files with 12 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ function dolStripPhpCode($str, $replacewith = '')
*
* @param string $str String to clean
* @return string Result string with php code only
* @see dolStripPhpCode()
* @see dolStripPhpCode(), checkPHPCode()
*/
function dolKeepOnlyPhpCode($str)
{

View File

@@ -678,6 +678,7 @@ function showWebsiteTemplates(Website $website)
* @param string $phpfullcodestringold PHP old string
* @param string $phpfullcodestring PHP new string
* @return int Error or not
* @see dolKeepOnlyPhpCode()
*/
function checkPHPCode($phpfullcodestringold, $phpfullcodestring)
{

View File

@@ -806,6 +806,16 @@ if ($action == 'addcontainer' && $usercanedit) {
// Remove comments
$tmp['content'] = removeHtmlComment($tmp['content']);
// Check there is no PHP content into the imported file (must be only HTML + JS)
$phpcontent = dolKeepOnlyPhpCode('', $tmp['content']);
if ($phpcontent) {
$error++;
setEventMessages('Error getting '.$urltograb.': file that include PHP content is not allowed', null, 'errors');
$action = 'createcontainer';
}
}
if (!$error) {
$regs = array();
preg_match('/<head>(.*)<\/head>/ims', $tmp['content'], $regs);