validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

IPv6 regex accepts invalid formats

Open zaelgohary opened this issue 3 years ago • 4 comments
trafficstars

Describe the bug IPv6 regex accepts invalid formats.

Examples

  • BC:e4d5:c:e7b9::%40i0nccymtl9cwfKo.5vaeXLSGRMe:EDh2qs5wkhnPws5xQKqafjfAMm6wGFCJ.bVFsZfb
  • 1dC:0DF8:62D:3AC::%KTatXocjaFVioS0RTNQl4mA.V151o0RSy.JIu-D-D8.d3171ZWsSJ7PK4YjkJCRN0F

Recommended Fix The issue can be fixed by changing lines 44 & 45 in isIP.js file to the following: (?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:)) + ')([0-9a-fA-F]{1})?$');

Additional context Validator.js version: 13.7.0 Node.js version: v16.14.2 OS platform: Linux

zaelgohary avatar Sep 13 '22 10:09 zaelgohary

Feel free to open a PR that fixes this and adds additional tests

WikiRik avatar Sep 13 '22 11:09 WikiRik

Tried to push the fix on a new branch and then open a PR but permission was denied as shown below. image

zaelgohary avatar Sep 13 '22 11:09 zaelgohary

You should push it to your own fork and then you can open a PR towards this repo

WikiRik avatar Sep 14 '22 15:09 WikiRik