Commit 06206e03 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(MacAttribute) Use pattern HTML5 attribute for Mac Address as well

issue #5910
parent f6c0c692
......@@ -166,7 +166,7 @@ class tests
*/
public static function is_mac($mac)
{
return preg_match("/^[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]$/i", $mac);
return preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $mac);
}
......
......@@ -118,16 +118,14 @@ class MacAddressAttribute extends StringAttribute
{
protected $trim = TRUE;
function setValue ($value)
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = '', $acl = '')
{
return parent::setValue(strtolower($value));
parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl, '/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', '5E:FF:56:A2:AF:15');
}
function validate ()
function setValue ($value)
{
if (!tests::is_mac($this->value)) {
return msgPool::invalid($this->getLabel(), $this->value);
}
return parent::setValue(strtolower($value));
}
}
......
  • SonarQube analysis reported 1 issue

    • 🔽 1 minor

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. 🔽 Remove this method "__construct" to simply inherit it. 📘
Supports Markdown
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