PAC-K014 · isinnet-with-ipv6

isInNet called with an IPv6 address

medium · Compatibility across engines

isInNet is defined for dotted-quad IPv4 addresses and masks. An IPv6 network or mask makes the test false on every engine; the IPv6-capable isInNetEx exists only in some engines.

Why it matters

The v1 helper parses four decimal octets. isInNet(host, "fd00::", "ffff::") is never true. isInNetEx(host, "fd00::/8") works for an IPv6 address in Chromium and Windows (WinHTTP) but throws in Firefox (PAC-K003); on Windows it is false when host is a name, because isInNetEx there does not look names up (lab, 2026-10-11). For the few IPv6 ranges that matter in a PAC (loopback, link-local, unique-local) a string prefix test is portable and sufficient.

How to fix

Use string tests for well-known IPv6 ranges (host == "::1", shExpMatch(host, "fe80:*")) or a guarded isInNetEx with fallback.

Examples

Bad

function FindProxyForURL(url, host) {
  if (isInNet(host, "fd00::", "ff00::")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open bad example in checker

Good

function FindProxyForURL(url, host) {
  if (shExpMatch(host, "fd*:*") || shExpMatch(host, "fc*:*")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open good example in checker

The PAC functions this rule is about

  • isInNet(): True if the IP address of host is in the network pattern/mask. Resolves host via DNS if it is not an IP literal.

Related rules

References

Last updated: