From 4a2f26415e819c563e91847779cff10cf644a4e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 23:36:41 +0100 Subject: [PATCH] Fix GETPOST accept < if followed with a number --- htdocs/core/lib/functions.lib.php | 4 ++-- test/phpunit/SecurityTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 99a66a9a682..b1129dcfb4f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5786,8 +5786,8 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = // Example of $temp: 0000-021 $temp = preg_replace($pattern, "", $temp); // pass 1 - $temp after pass 1: 0000-021 $temp = preg_replace($pattern, "", $temp); // pass 2 - $temp after pass 2: 0000-021 - // removed '<' into non closing html tags like 'objnotdefined\''; $_POST["param11"]=' Name '; @@ -371,6 +373,14 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml'); + $result=GETPOST("param8d", 'alphanohtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml'); + + $result=GETPOST("param8e", 'alphanohtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml'); + $result=GETPOST("param9", 'alphanohtml'); print __METHOD__." result=".$result."\n"; $this->assertEquals($_POST["param9"], $result);