Skip to content
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

Zone Index is discarded for IPv4-mapped IPv6 (transitional) addresses #79

Closed
JamesMGreene opened this issue Aug 21, 2017 · 4 comments
Closed

Comments

@JamesMGreene
Copy link
Contributor

Zone Index is discarded for IPv4-mapped IPv6 (transitional) addresses

var ipaddr = require('ipaddr.js')

addr = ipaddr.parse('::ff:ffff:c0a8:101%eth0')
// IPv6 { parts: [ 0, 0, 0, 0, 255, 65535, 49320, 257 ], zoneId: 'eth0' }

addr = ipaddr.parse('::ffff:c0a8:101%z')
// IPv6 { parts: [ 0, 0, 0, 0, 0, 65535, 49320, 257 ], zoneId: 'z' }

// This result is missing its zone index "map"
addr = ipaddr.parse('::ffff:192.168.1.1%map')
// IPv6 { parts: [ 0, 0, 0, 0, 0, 65535, 49320, 257 ] }

cc: @silverwind

@silverwind
Copy link
Contributor

silverwind commented Aug 21, 2017

Something about the transitional regexp not matching the zoneId. Now if only I knew what match[1][0..-2] does in CoffeeScript :)

@JamesMGreene
Copy link
Contributor Author

I think I fixed it but I'm trying to figure out where to add a unit test for this one.

@JamesMGreene
Copy link
Contributor Author

And match[1][0..-2] somehow seems to translate to match[1].slice(0, -1). Oh, CoffeeScript.... 😕

@silverwind
Copy link
Contributor

silverwind commented Aug 21, 2017

Here's my version of the fix, but go ahead and commit/PR yours:

   else if match = string.match(ipv6Regexes['transitional'])
-    addr = expandIPv6(match[1][0..-2], 6)
+    addr = expandIPv6(match[1][0..-2] + (match[6] || ''), 6)
     if addr.parts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants