diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 6823b891139..dab70304d08 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -102,8 +102,8 @@ if (GETPOST('datep')) {
// Security check
$socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int');
-if ($user->socid) {
- $socid = $user->socid;
+if ($user->socid && ($socid != $user->socid)) {
+ accessforbidden();
}
$error = GETPOST("error");
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index d900b7718cf..16245427a6f 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -35,8 +35,10 @@ function dolStripPhpCode($str, $replacewith = '')
$newstr = '';
- //split on each opening tag
- $parts = explode('addTestSuite('AccountingAccountTest');
+ // Rest
require_once dirname(__FILE__).'/RestAPIUserTest.php';
$suite->addTestSuite('RestAPIUserTest');
require_once dirname(__FILE__).'/RestAPIDocumentTest.php';
@@ -272,6 +273,10 @@ class AllTests
require_once dirname(__FILE__).'/EmailCollectorTest.php';
$suite->addTestSuite('EmailCollectorTest');
+ // Website
+ require_once dirname(__FILE__).'/WebsiteTest.php';
+ $suite->addTestSuite('Website');
+
return $suite;
}
}
diff --git a/test/phpunit/Website.class.php b/test/phpunit/WebsiteTest.class.php
similarity index 91%
rename from test/phpunit/Website.class.php
rename to test/phpunit/WebsiteTest.class.php
index 50d0c16453d..2f0afbbed96 100644
--- a/test/phpunit/Website.class.php
+++ b/test/phpunit/WebsiteTest.class.php
@@ -175,4 +175,22 @@ class WebsiteTest extends PHPUnit\Framework\TestCase
// We must found no line (so code should be KO). If we found somethiing, it means there is a SQL injection of the 1=1
$this->assertEquals($res['code'], 'KO');
}
+
+ /**
+ * testDolStripPhpCode
+ *
+ * @return void
+ */
+ public function testDolStripPhpCode()
+ {
+ global $db;
+
+ $s = "abc\nghi";
+ $result = dolStripPhpCode($s);
+ $this->assertEquals("abc\nghi", $result);
+
+ $s = "abc\nghi";
+ $result = dolStripPhpCode($s);
+ $this->assertEquals("abc\nghi", $result);
+ }
}