-
Notifications
You must be signed in to change notification settings - Fork 166
fix: reject MAC addresses with mixed separators #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add validation to prevent MAC addresses that use both ':' and '-' separators simultaneously, ensuring consistent separator usage as per MAC address format standards.
Hi @iCasture, can you please provide a reference to where such a requirement is specified. |
According to IEEE 802-2014, two textual representations were defined:
RFC 7043 is explicit:
In practice, people also write MAC addresses with colons instead of hyphens, and sometimes even with dots — even though the IEEE format is hyphen-separated. For example, Wikipedia: Notational conventions and Talk:MAC address: Canonical presentation format mention this usage:
Cisco documentation explicitly lists the three supported formats:
Microsoft’s .NET PhysicalAddress.Parse Method likewise accepts:
Go’s net.ParseMAC function accepts the following formats:
So basically, the examples show that you can write a MAC address with hyphens, colons, dots, or just no separators at all — but you’ve got to pick one style and stick with it. There’s no spec or implementation that allows mixing If we want to be more flexible, we could also support the dotted form ( Reference: |
Thanks for that @iCasture ! |
Previously, the MAC address validator would accept invalid MAC addresses that mixed different separators, such as
aa:bb-cc-dd:ee:ff
, but a valid MAC address should use consistent separators throughout.This PR improves the MAC address validator by adding a check to reject MAC addresses that use mixed separators (both
:
and-
characters).