diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 48f7c2ce..c7922fcd 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -224,7 +224,7 @@ class m_ftp { } // Explicitly look for only allowed chars - if ( ! preg_match("/^[A-Za-z0-9_\.\-]+$/", $l) ) { + if ( ! preg_match("/^[A-Za-z0-9]+[A-Za-z0-9_\.\-]*$/", $l) ) { $err->raise('ftp', _("FTP login is incorrect")); return false; } diff --git a/phpunit/tests/bureau/class/m_ftpTest.php b/phpunit/tests/bureau/class/m_ftpTest.php index dccf94b5..85251f26 100644 --- a/phpunit/tests/bureau/class/m_ftpTest.php +++ b/phpunit/tests/bureau/class/m_ftpTest.php @@ -118,10 +118,13 @@ class m_ftpTest extends PHPUnit_Framework_TestCase */ public function testCheck_login() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + // Allowed + $this->assertTrue($this->object->check_login('plop')); + $this->assertTrue($this->object->check_login('00')); + + // Forbidden + $this->assertFalse($this->object->check_login('_plop')); + $this->assertFalse($this->object->check_login('arf+')); } /** @@ -238,9 +241,6 @@ class m_ftpTest extends PHPUnit_Framework_TestCase */ public function testHook_upnp_list() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertArrayHasKey('ftp', $this->object->hook_upnp_list()); } }