diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index d4c3e66394e..9b6616ea551 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -58,14 +58,6 @@ if (is_numeric($entity)) {
// Load Dolibarr environment
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
-if (isModEnabled('paypal')) {
- require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
-}
-
/**
* @var Conf $conf
* @var DoliDB $db
@@ -76,6 +68,13 @@ if (isModEnabled('paypal')) {
*
* @var string $dolibarr_main_url_root
*/
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+if (isModEnabled('paypal')) {
+ require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
+}
// Hook to be used by external payment modules (ie Payzen, ...)
$hookmanager = new HookManager($db);
diff --git a/test/phpunit/SecurityGETPOSTTest.php b/test/phpunit/SecurityGETPOSTTest.php
index 888d8e00ef3..9a71d96b283 100644
--- a/test/phpunit/SecurityGETPOSTTest.php
+++ b/test/phpunit/SecurityGETPOSTTest.php
@@ -315,12 +315,6 @@ class SecurityGETPOSTTest extends CommonClassTest
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
- $_POST["pagecontentwithaconstantvarinurl"] = 'https://[__aaa__]/aaa.html';
- $result = GETPOST("pagecontentwithaconstantvarinurl", 'restricthtml');
- print __METHOD__." result=".$result."\n";
- $this->assertEquals('https://[__aaa__]/aaa.html', $result, 'Test on HTML content with url with constant');
-
-
//$_POST["param0"] = 'A real string with aaa and " inside content';
$result = GETPOST("param0", 'restricthtml');
@@ -343,6 +337,11 @@ class SecurityGETPOSTTest extends CommonClassTest
//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
//$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned
+ $_POST["pagecontentwithaconstantvarinurl"] = 'https://[__aaa__]/aaa.html';
+ $result = GETPOST("pagecontentwithaconstantvarinurl", 'restricthtml');
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals('https://[__aaa__]/aaa.html', $result, 'Test on HTML content with url with constant');
+
// Test with restricthtml + MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY only to test disabling of bad attributes