-
Notifications
You must be signed in to change notification settings - Fork 3
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
Validate "X-PSU-IP-Address" against pattern #87
base: main
Are you sure you want to change the base?
Conversation
Just be careful, your regex doesn't include IPv6, but IPv6 values are valid to be included in |
(([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}) Could someone verify, if this is really a valid IPv6. |
@dkoeni : Kannst du dies beurteilen? |
This pattern is not valid since it does not match e.g. FF01::101, which is a valid IPv6 address. To come up with a good regex for IPv6 is rather tricky because there isn't a single pattern to match. For example, 0:0:0:0:0:FFFF:8190:0726, 0:0:0:0:0:FFFF:8190:726, ::FFFF:8190:0726, ::FFFF:8190:726, ::FFFF:129.144.7.38, and 0:0:0:0:0:FFFF:129.144.7.38 are valid representations of the same IPv6 address (RFC 4291, Section 2.2, and there are actually more representations added in later RFCs). So the proper pattern to match all those cases would be which corresponds to
However regex101 does not verify that this regex match the address ffff::ffff even it should be as line 4 matches this pattern. To conclude I would suggest to allow only specific representations of IPv6 to implement a more efficient Regex pattern, if this is suitable in context of the API use cases. |
Just a little more strict definition