Commit 57181a65 authored by Noe Nieto's avatar Noe Nieto 💬

Update plugin description and add a new test case for unicode characters; see liberty/internal#32

parent 1e1afe0e
Pipeline #3379 passed with stage
in 25 seconds
......@@ -8,47 +8,52 @@ final class PolicyTest extends TestCase
{
public function testPolicy_usernames(): void
{
// Remove all characters after the first "@"
// Remove all characters after the first "@"
$this->assertEquals(
sanitize_username('foo@example.com'),
'foo'
sanitize_username('foo@example.com'),
'foo'
);
// Remove all remaining non-alphanumeric characters
// Remove all remaining non-alphanumeric characters
$this->assertEquals(
sanitize_username('valid+email@example.com'),
'validemail'
sanitize_username('valid+email@example.com'),
'validemail'
);
$this->assertEquals(
sanitize_username('valid.email@example.com'),
'validemail'
sanitize_username('valid.email@example.com'),
'validemail'
);
$this->assertEquals(
sanitize_username('valid-email@example.com'),
'validemail'
sanitize_username('valid-email@example.com'),
'validemail'
);
$this->assertEquals(
sanitize_username(')(*&l^%!o#$^l%1#3^3#7$'),
'lol1337'
sanitize_username(')(*&l^%!o#$^l%1#3^3#7$'),
'lol1337'
);
// If username starts with a numeral, prepend an "x"
$this->assertEquals(
sanitize_username('029822c@example.com'),
'x029822c'
sanitize_username('029822c@example.com'),
'x029822c'
);
$this->assertEquals(
sanitize_username('123456789@example.com'),
'x123456789'
sanitize_username('123456789@example.com'),
'x123456789'
);
// Set all letters to lowercase
$this->assertEquals(
sanitize_username('exAmpleRWEFS@example.com'),
'examplerwefs'
sanitize_username('exAmpleRWEFS@example.com'),
'examplerwefs'
);
// Set all letters to lowercase
$this->assertEquals(
sanitize_username('unicodə@example.com'),
'unicod'
);
}
}
......@@ -4,8 +4,8 @@
* @version 0.1
Plugin Name: Purism's usernames policy
Plugin URI: https://source.puri.sm/liberty/internal/issues/32
Description: Wordpress creates usernames from email addresses. These could be invalid Purist usernames, for example p.Sherman. These should be autocorrected to follow Purist rules, for example psherman.
Author: Copyright 2018 Purism SPC
Description: Wordpress creates usernames from email addresses. These could be invalid Purist usernames, for example p.Sherman. These should be autocorrected to follow Purist rules.
Author: Purism SPC
Version: 0.1
Author URI: http://www.puri.sm/
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment