trim email address when added as forwarder, fixes #591
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -63,6 +63,9 @@ class EmailForwarders extends ApiCommand implements ResourceEntity
|
|||||||
// current destination array
|
// current destination array
|
||||||
$result['destination_array'] = explode(' ', $result['destination']);
|
$result['destination_array'] = explode(' ', $result['destination']);
|
||||||
|
|
||||||
|
// prepare destination
|
||||||
|
$destination = trim($destination);
|
||||||
|
|
||||||
if (! validateEmail($destination)) {
|
if (! validateEmail($destination)) {
|
||||||
standard_error('destinationiswrong', $destination, true);
|
standard_error('destinationiswrong', $destination, true);
|
||||||
} elseif ($destination == $result['email']) {
|
} elseif ($destination == $result['email']) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @covers ApiCommand
|
* @covers ApiCommand
|
||||||
* @covers ApiParameter
|
* @covers ApiParameter
|
||||||
* @covers Emails
|
* @covers Emails
|
||||||
@@ -100,6 +101,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAdd
|
* @depends testCustomerEmailForwardersAdd
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersAddNoMoreResources()
|
public function testCustomerEmailForwardersAddNoMoreResources()
|
||||||
@@ -118,6 +120,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAddNoMoreResources
|
* @depends testCustomerEmailForwardersAddNoMoreResources
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersAddEmailHidden()
|
public function testCustomerEmailForwardersAddEmailHidden()
|
||||||
@@ -137,6 +140,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAddEmailHidden
|
* @depends testCustomerEmailForwardersAddEmailHidden
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersDeleteEmailHidden()
|
public function testCustomerEmailForwardersDeleteEmailHidden()
|
||||||
@@ -156,6 +160,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersDeleteEmailHidden
|
* @depends testCustomerEmailForwardersDeleteEmailHidden
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersAddAnother()
|
public function testCustomerEmailForwardersAddAnother()
|
||||||
@@ -180,6 +185,32 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* @depends testCustomerEmailForwardersDeleteEmailHidden
|
||||||
|
*/
|
||||||
|
public function testCustomerEmailForwardersAddWithSpaces()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
|
||||||
|
Settings::Set('panel.customer_hide_options', '', true);
|
||||||
|
|
||||||
|
// get customer
|
||||||
|
$json_result = Customers::getLocal($admin_userdata, array(
|
||||||
|
'loginname' => 'test1'
|
||||||
|
))->get();
|
||||||
|
$customer_userdata = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'emailaddr' => 'info@test2.local',
|
||||||
|
'destination' => 'other3@domain.tld '
|
||||||
|
];
|
||||||
|
$json_result = EmailForwarders::getLocal($customer_userdata, $data)->add();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals('other@domain.tld other2@domain.tld other3@domain.tld', $result['destination']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAdd
|
* @depends testCustomerEmailForwardersAdd
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersAddExistingAsMail()
|
public function testCustomerEmailForwardersAddExistingAsMail()
|
||||||
@@ -201,6 +232,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAdd
|
* @depends testCustomerEmailForwardersAdd
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersAddExistingAsDestination()
|
public function testCustomerEmailForwardersAddExistingAsDestination()
|
||||||
@@ -261,6 +293,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAddAnother
|
* @depends testCustomerEmailForwardersAddAnother
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersDelete()
|
public function testCustomerEmailForwardersDelete()
|
||||||
@@ -283,6 +316,7 @@ class MailsTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @depends testCustomerEmailForwardersAddAnother
|
* @depends testCustomerEmailForwardersAddAnother
|
||||||
*/
|
*/
|
||||||
public function testCustomerEmailForwardersDeleteUnknown()
|
public function testCustomerEmailForwardersDeleteUnknown()
|
||||||
@@ -405,7 +439,7 @@ class MailsTest extends TestCase
|
|||||||
global $admin_userdata;
|
global $admin_userdata;
|
||||||
|
|
||||||
// remove possible existing delete tasks
|
// remove possible existing delete tasks
|
||||||
Database::query("TRUNCATE `".TABLE_PANEL_TASKS."`");
|
Database::query("TRUNCATE `" . TABLE_PANEL_TASKS . "`");
|
||||||
|
|
||||||
Settings::Set('panel.sendalternativemail', 0, true);
|
Settings::Set('panel.sendalternativemail', 0, true);
|
||||||
// get customer
|
// get customer
|
||||||
|
|||||||
Reference in New Issue
Block a user