Add a check on syntax of hostname for email colector

This commit is contained in:
Laurent Destailleur 2021-02-09 13:59:00 +01:00
parent c9f34cc0d4
commit 4a97690f78
2 changed files with 19 additions and 0 deletions

View File

@ -251,6 +251,15 @@ class EmailCollector extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
global $langs;
// Check parameters
if ($this->host && preg_match('/^http:/i', trim($this->host))) {
$langs->load("errors");
$this->error = $langs->trans("ErrorHostMustNotStartWithHttp", $this->host);
return -1;
}
$id = $this->createCommon($user, $notrigger);
if (is_array($this->filters) && count($this->filters)) {
@ -449,6 +458,15 @@ class EmailCollector extends CommonObject
*/
public function update(User $user, $notrigger = false)
{
global $langs;
// Check parameters
if ($this->host && preg_match('/^http:/i', trim($this->host))) {
$langs->load("errors");
$this->error = $langs->trans("ErrorHostMustNotStartWithHttp", $this->host);
return -1;
}
return $this->updateCommon($user, $notrigger);
}

View File

@ -227,6 +227,7 @@ ErrorDuringChartLoad=Error when loading chart of accounts. If few accounts were
ErrorBadSyntaxForParamKeyForContent=Bad syntax for param keyforcontent. Must have a value starting with %s or %s
ErrorVariableKeyForContentMustBeSet=Error, the constant with name %s (with text content to show) or %s (with external url to show) must be set.
ErrorURLMustStartWithHttp=URL %s must start with http:// or https://
ErrorHostMustNotStartWithHttp=Host name %s must NOT start with http:// or https://
ErrorNewRefIsAlreadyUsed=Error, the new reference is already used
ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible=Error, delete payment linked to a closed invoice is not possible.
ErrorSearchCriteriaTooSmall=Search criteria too small.