@@ -25,36 +25,36 @@ discard block |
||
25 | 25 | * \remarks To run this script as CLI: phpunit filename.php |
26 | 26 | */ |
27 | 27 | |
28 | -global $conf,$user,$langs,$db; |
|
28 | +global $conf, $user, $langs, $db; |
|
29 | 29 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
30 | 30 | //require_once 'PHPUnit/Autoload.php'; |
31 | 31 | |
32 | -if (! defined('NOREQUIRESOC')) { |
|
32 | +if (!defined('NOREQUIRESOC')) { |
|
33 | 33 | define('NOREQUIRESOC', '1'); |
34 | 34 | } |
35 | -if (! defined('NOCSRFCHECK')) { |
|
35 | +if (!defined('NOCSRFCHECK')) { |
|
36 | 36 | define('NOCSRFCHECK', '1'); |
37 | 37 | } |
38 | -if (! defined('NOTOKENRENEWAL')) { |
|
38 | +if (!defined('NOTOKENRENEWAL')) { |
|
39 | 39 | define('NOTOKENRENEWAL', '1'); |
40 | 40 | } |
41 | -if (! defined('NOREQUIREMENU')) { |
|
41 | +if (!defined('NOREQUIREMENU')) { |
|
42 | 42 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
43 | 43 | } |
44 | -if (! defined('NOREQUIREHTML')) { |
|
44 | +if (!defined('NOREQUIREHTML')) { |
|
45 | 45 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
46 | 46 | } |
47 | -if (! defined('NOREQUIREAJAX')) { |
|
47 | +if (!defined('NOREQUIREAJAX')) { |
|
48 | 48 | define('NOREQUIREAJAX', '1'); |
49 | 49 | } |
50 | -if (! defined("NOLOGIN")) { |
|
51 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
50 | +if (!defined("NOLOGIN")) { |
|
51 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
52 | 52 | } |
53 | -if (! defined("NOSESSION")) { |
|
53 | +if (!defined("NOSESSION")) { |
|
54 | 54 | define("NOSESSION", '1'); |
55 | 55 | } |
56 | 56 | |
57 | -require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. |
|
57 | +require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. |
|
58 | 58 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
59 | 59 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
60 | 60 | require_once dirname(__FILE__).'/CommonClassTest.class.php'; |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $result = testSqlAndScriptInject($test, 0); |
229 | 229 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
230 | 230 | |
231 | - $test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
232 | - $test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
231 | + $test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
232 | + $test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
233 | 233 | |
234 | 234 | $test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
235 | 235 | $result = testSqlAndScriptInject($test, 0); |
@@ -263,21 +263,21 @@ discard block |
||
263 | 263 | $result = testSqlAndScriptInject($test, 0); |
264 | 264 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll'); |
265 | 265 | |
266 | - $test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
266 | + $test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
267 | 267 | $result = testSqlAndScriptInject($test, 0); |
268 | 268 | //print "test=".$test." result=".$result."\n"; |
269 | 269 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm'); |
270 | 270 | |
271 | 271 | |
272 | 272 | $test = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submitted by CKEditor)"; |
273 | - $result = testSqlAndScriptInject($test, 0); // result must be 0 |
|
273 | + $result = testSqlAndScriptInject($test, 0); // result must be 0 |
|
274 | 274 | $this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not'); |
275 | 275 | |
276 | 276 | $test = '<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
277 | 277 | $result = testSqlAndScriptInject($test, 0); |
278 | 278 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not'); |
279 | 279 | |
280 | - $test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
280 | + $test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
281 | 281 | $result = testSqlAndScriptInject($test, 2); |
282 | 282 | //print "test=".$test." result=".$result."\n"; |
283 | 283 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char'); |
@@ -389,21 +389,21 @@ discard block |
||
389 | 389 | { |
390 | 390 | global $conf; |
391 | 391 | |
392 | - $genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
392 | + $genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
393 | 393 | print __METHOD__." genpass1=".$genpass1."\n"; |
394 | 394 | $this->assertEquals(strlen($genpass1), 32); |
395 | 395 | |
396 | - $genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
396 | + $genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
397 | 397 | print __METHOD__." genpass1=".$genpass1."\n"; |
398 | 398 | $this->assertEquals(strlen($genpass1), 32); |
399 | 399 | |
400 | 400 | $conf->global->USER_PASSWORD_GENERATED = 'None'; |
401 | - $genpass2 = getRandomPassword(false); // Should return an empty string |
|
401 | + $genpass2 = getRandomPassword(false); // Should return an empty string |
|
402 | 402 | print __METHOD__." genpass2=".$genpass2."\n"; |
403 | 403 | $this->assertEquals($genpass2, ''); |
404 | 404 | |
405 | 405 | $conf->global->USER_PASSWORD_GENERATED = 'Standard'; |
406 | - $genpass3 = getRandomPassword(false); // Should return a password of 12 chars |
|
406 | + $genpass3 = getRandomPassword(false); // Should return a password of 12 chars |
|
407 | 407 | print __METHOD__." genpass3=".$genpass3."\n"; |
408 | 408 | $this->assertEquals(strlen($genpass3), 12); |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function testRestrictedArea() |
419 | 419 | { |
420 | - global $conf,$user,$langs,$db; |
|
420 | + global $conf, $user, $langs, $db; |
|
421 | 421 | $conf = $this->savconf; |
422 | 422 | $user = $this->savuser; |
423 | 423 | $langs = $this->savlangs; |
@@ -448,40 +448,40 @@ discard block |
||
448 | 448 | $tmpvar = preg_match('/not supported/', $tmp['curl_error_msg']); |
449 | 449 | $this->assertEquals(1, $tmpvar, "Did not find the /not supported/ in getURLContent error message. We should."); |
450 | 450 | |
451 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
452 | - $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
451 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
452 | + $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
453 | 453 | print __METHOD__." url=".$url."\n"; |
454 | 454 | $this->assertEquals(301, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 response'); |
455 | 455 | |
456 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
457 | - $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
456 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
457 | + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
458 | 458 | print __METHOD__." url=".$url."\n"; |
459 | 459 | $this->assertEquals(200, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 with a follow -> 200 but we get '.(empty($tmp['http_code']) ? 0 : $tmp['http_code'])); |
460 | 460 | |
461 | 461 | $url = 'http://localhost'; |
462 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
462 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
463 | 463 | print __METHOD__." url=".$url."\n"; |
464 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
464 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
465 | 465 | |
466 | 466 | $url = 'http://127.0.0.1'; |
467 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
467 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
468 | 468 | print __METHOD__." url=".$url."\n"; |
469 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
469 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
470 | 470 | |
471 | 471 | $url = 'http://127.0.2.1'; |
472 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
472 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
473 | 473 | print __METHOD__." url=".$url."\n"; |
474 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
474 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
475 | 475 | |
476 | 476 | $url = 'https://169.254.0.1'; |
477 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
477 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
478 | 478 | print __METHOD__." url=".$url."\n"; |
479 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
479 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
480 | 480 | |
481 | 481 | $url = 'http://[::1]'; |
482 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
482 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
483 | 483 | print __METHOD__." url=".$url."\n"; |
484 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
484 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
485 | 485 | |
486 | 486 | /*$url = 'localtest.me'; |
487 | 487 | $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | */ |
491 | 491 | |
492 | 492 | $url = 'http://192.0.0.192'; |
493 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
493 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
494 | 494 | print __METHOD__." url=".$url." tmp['http_code'] = ".(empty($tmp['http_code']) ? 0 : $tmp['http_code'])."\n"; |
495 | - $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
495 | + $this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
496 | 496 | |
497 | 497 | return 0; |
498 | 498 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function testDolSanitizeUrl() |
506 | 506 | { |
507 | - global $conf,$user,$langs,$db; |
|
507 | + global $conf, $user, $langs, $db; |
|
508 | 508 | $conf = $this->savconf; |
509 | 509 | $user = $this->savuser; |
510 | 510 | $langs = $this->savlangs; |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function testDolSanitizeEmail() |
532 | 532 | { |
533 | - global $conf,$user,$langs,$db; |
|
533 | + global $conf, $user, $langs, $db; |
|
534 | 534 | $conf = $this->savconf; |
535 | 535 | $user = $this->savuser; |
536 | 536 | $langs = $this->savlangs; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function testDolSanitizeFileName() |
562 | 562 | { |
563 | - global $conf,$user,$langs,$db; |
|
563 | + global $conf, $user, $langs, $db; |
|
564 | 564 | $conf = $this->savconf; |
565 | 565 | $user = $this->savuser; |
566 | 566 | $langs = $this->savlangs; |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | */ |
584 | 584 | public function testDolEval() |
585 | 585 | { |
586 | - global $conf,$user,$langs,$db; |
|
586 | + global $conf, $user, $langs, $db; |
|
587 | 587 | $conf = $this->savconf; |
588 | 588 | $user = $this->savuser; |
589 | 589 | $langs = $this->savlangs; |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
594 | 594 | include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
595 | 595 | |
596 | - $result = dol_eval('1==\x01', 1, 0); // Check that we can't make dol_eval on string containing \ char. |
|
596 | + $result = dol_eval('1==\x01', 1, 0); // Check that we can't make dol_eval on string containing \ char. |
|
597 | 597 | print "result0 = ".$result."\n"; |
598 | 598 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
599 | 599 | |
@@ -640,12 +640,12 @@ discard block |
||
640 | 640 | // Now string not allowed |
641 | 641 | |
642 | 642 | $s = '4 <5'; |
643 | - $result = (string) dol_eval($s, 1, 1, '2'); // in mode 2, char < is allowed only if followed by a space |
|
643 | + $result = (string) dol_eval($s, 1, 1, '2'); // in mode 2, char < is allowed only if followed by a space |
|
644 | 644 | print "result = ".$result."\n"; |
645 | 645 | $this->assertStringContainsString('Bad string syntax to evaluate', $result, 'Test 4 <5 - The string was not detected as evil'); |
646 | 646 | |
647 | 647 | $s = '4 < 5'; |
648 | - $result = (string) dol_eval($s, 1, 1, '1'); // in mode 1, char < is always forbidden |
|
648 | + $result = (string) dol_eval($s, 1, 1, '1'); // in mode 1, char < is always forbidden |
|
649 | 649 | print "result = ".$result."\n"; |
650 | 650 | $this->assertStringContainsString('Bad string syntax to evaluate', $result, 'Test 4 < 5 - The string was not detected as evil'); |
651 | 651 | |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | print "result = ".$result."\n"; |
660 | 660 | $this->assertStringContainsString('Bad string syntax to evaluate', $result, 'The string was not detected as evil'); |
661 | 661 | |
662 | - $result = dol_eval('$a=function() { }; $a', 1, 1, '0'); // result of dol_eval may be an object Closure |
|
662 | + $result = dol_eval('$a=function() { }; $a', 1, 1, '0'); // result of dol_eval may be an object Closure |
|
663 | 663 | print "result5 = ".json_encode($result)."\n"; |
664 | 664 | $this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil'); |
665 | 665 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | |
702 | 702 | // Must be allowed |
703 | 703 | |
704 | - global $leftmenu; // Used into strings to eval |
|
704 | + global $leftmenu; // Used into strings to eval |
|
705 | 705 | |
706 | 706 | $leftmenu = 'AAA'; |
707 | 707 | $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
@@ -725,13 +725,13 @@ discard block |
||
725 | 725 | $this->assertFalse($result); |
726 | 726 | |
727 | 727 | $leftmenu = 'XXX'; |
728 | - $conf->global->MAIN_FEATURES_LEVEL = 1; // Force for the case option is -1 |
|
728 | + $conf->global->MAIN_FEATURES_LEVEL = 1; // Force for the case option is -1 |
|
729 | 729 | $string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; |
730 | 730 | $result = dol_eval($string, 1, 1, '1'); |
731 | 731 | print "result17 = ".$result."\n"; |
732 | 732 | $this->assertTrue($result); |
733 | 733 | |
734 | - $result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
734 | + $result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
735 | 735 | print "result18 = ".$result."\n"; |
736 | 736 | $this->assertFalse($result); |
737 | 737 | |
@@ -771,12 +771,12 @@ discard block |
||
771 | 771 | global $conf; |
772 | 772 | |
773 | 773 | // Set options for cleaning data |
774 | - $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
774 | + $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
775 | 775 | // Enabled option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY if possible |
776 | 776 | if (extension_loaded('tidy') && class_exists("tidy")) { |
777 | 777 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
778 | 778 | } |
779 | - $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
779 | + $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
780 | 780 | |
781 | 781 | |
782 | 782 | // For a string that is already HTML (contains HTML tags) with special tags but badly formatted |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | //$result = dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($stringtotest), 1, 1, 1, 0)), 1, 1, 'common', 0, 1); |
789 | 789 | $result = dolPrintHTML($stringtotest); |
790 | 790 | print __METHOD__." result=".$result."\n"; |
791 | - $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
791 | + $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
792 | 792 | |
793 | 793 | |
794 | 794 | // For a string that is already HTML (contains HTML tags) with special tags but badly formatted |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | // With cleaning options of HTML TIDY |
858 | 858 | if (extension_loaded('tidy') && class_exists("tidy")) { |
859 | 859 | $stringtotest = "Message<br>with ' and è and ' !"; |
860 | - $stringexpected = "Message<br>\nwith ' and è and ' !"; // The ' is modified into ' because html tidy fix it. |
|
860 | + $stringexpected = "Message<br>\nwith ' and è and ' !"; // The ' is modified into ' because html tidy fix it. |
|
861 | 861 | /* |
862 | 862 | var_dump($stringtotest); |
863 | 863 | var_dump(dol_htmlentitiesbr($stringtotest)); |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | $this->assertEquals('a', $result); |
890 | 890 | |
891 | 891 | // Test that testRealCharforNumericEntities return an emoji utf8 char when code is inside Emoji range |
892 | - $arraytmp = array(0 => '✅', 1 => '9989;'); // Encoded as decimal |
|
892 | + $arraytmp = array(0 => '✅', 1 => '9989;'); // Encoded as decimal |
|
893 | 893 | $result = realCharForNumericEntities($arraytmp); |
894 | 894 | $this->assertEquals('✅', $result); |
895 | 895 | |
896 | - $arraytmp = array(0 => '✅', 1 => 'x2705;'); // Encoded as hexadecimal |
|
896 | + $arraytmp = array(0 => '✅', 1 => 'x2705;'); // Encoded as hexadecimal |
|
897 | 897 | $result = realCharForNumericEntities($arraytmp); |
898 | 898 | $this->assertEquals('✅', $result); |
899 | 899 | |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | // For a string with js and link with restricthtmlallowlinkscript |
964 | 964 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
965 | 965 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; |
966 | - $s='<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
966 | + $s = '<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
967 | 967 | <link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> |
968 | 968 | <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
969 | 969 | <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'; |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | // For a string with js and link with restricthtmlallowlinkscript |
977 | 977 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
978 | 978 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
979 | - $s='<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
979 | + $s = '<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
980 | 980 | <link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> |
981 | 981 | <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
982 | 982 | <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | // For a string with js and link with restricthtmlallowlinkscript |
990 | 990 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; |
991 | 991 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; |
992 | - $s='<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
992 | + $s = '<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700"> |
|
993 | 993 | <link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> |
994 | 994 | <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
995 | 995 | <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'; |