From 185980c9c687013e538838cf525085b389c76c2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Aug 2022 22:55:09 +0200 Subject: [PATCH] Enhance protection on limit of external links --- htdocs/core/lib/functions.lib.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7edfd6d6689..8ef4fb4ede6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -954,12 +954,15 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options // Restore entity ' into ' (restricthtml is for html content so we can use html entity) $out = preg_replace('/'/i', "'", $out); - - preg_match_all('/( getDolGlobalInt("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) { - $out = ''; - } } while ($oldstringtoclean != $out); + + // Check the limit of external links in a Rich text content. We count ' getDolGlobalInt("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) { + return 'TooManyLinksIntoHTMLString'; + } + break; case 'custom': if (empty($filter)) {