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
|
||||
$result['destination_array'] = explode(' ', $result['destination']);
|
||||
|
||||
// prepare destination
|
||||
$destination = trim($destination);
|
||||
|
||||
if (! validateEmail($destination)) {
|
||||
standard_error('destinationiswrong', $destination, true);
|
||||
} elseif ($destination == $result['email']) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @covers ApiCommand
|
||||
* @covers ApiParameter
|
||||
* @covers Emails
|
||||
@@ -100,6 +101,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAdd
|
||||
*/
|
||||
public function testCustomerEmailForwardersAddNoMoreResources()
|
||||
@@ -118,6 +120,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAddNoMoreResources
|
||||
*/
|
||||
public function testCustomerEmailForwardersAddEmailHidden()
|
||||
@@ -137,6 +140,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAddEmailHidden
|
||||
*/
|
||||
public function testCustomerEmailForwardersDeleteEmailHidden()
|
||||
@@ -156,6 +160,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersDeleteEmailHidden
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public function testCustomerEmailForwardersAddExistingAsMail()
|
||||
@@ -201,6 +232,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAdd
|
||||
*/
|
||||
public function testCustomerEmailForwardersAddExistingAsDestination()
|
||||
@@ -261,6 +293,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAddAnother
|
||||
*/
|
||||
public function testCustomerEmailForwardersDelete()
|
||||
@@ -283,6 +316,7 @@ class MailsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerEmailForwardersAddAnother
|
||||
*/
|
||||
public function testCustomerEmailForwardersDeleteUnknown()
|
||||
|
||||
Reference in New Issue
Block a user