# PAC helper called with the wrong number of arguments

Source: https://findproxyforurl.net/rules/pac-function-wrong-arity/ · last updated 2026-10-11

Rule PAC-E017 (`pac-function-wrong-arity`), severity high, category: Errors and robustness.

A built-in PAC helper is called with too few or too many arguments. In the browsers missing arguments are undefined, which makes the helper return false or an unexpected value for every host. Windows (WinHTTP) raises an error for many such calls, which ends the script.

## Why it matters

A wrong argument count is not caught when the file is loaded. In the browsers the helpers are
plain JavaScript functions: `dnsDomainIs(host)` compares against undefined and
`shExpMatch(host, "a", "b")` ignores the third argument, so the branch is silently wrong.
`isInNet(host, "10.0.0.0")` depends on the engine: Chrome, Edge and Firefox return false,
while pactester (pacparser) and Windows (WinHTTP) throw an error that ends the whole
evaluation (lab, 2026-10-11). In the same lab run Windows also threw for an extra argument,
for example `isPlainHostName("a", "b")` and `isInNet` with four arguments, and for a missing
one, for example `isPlainHostName()`. Either way the rule does not do what it says.


## How to fix

Check the helper signature (isInNet needs host, network, mask; dnsDomainIs and shExpMatch need host and pattern).

## Bad

```js
function FindProxyForURL(url, host) {
  if (isInNet(host, "10.0.0.0")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (isInNet(host, "10.0.0.0", "255.0.0.0")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- winhttp: isPlainHostName, isInNet and weekdayRange raised an error that ends the script when an argument was missing, extra or null, for example isPlainHostName(), isPlainHostName("a", "b"), isInNet with two or four arguments and weekdayRange(null). dateRange() and timeRange() without arguments returned false. (source: lab, verified 2026-10-11)
