PAC-C003 · invalid-host-pattern-characters

Path, port or query characters in a host pattern

medium · Correctness

host contains no slash, colon, question mark, space or port. A host pattern with any of these can never match.

Why it matters

Hostnames consist of letters, digits, hyphens and dots (IP literals of digits and dots). shExpMatch(host, "www.corp.example/app"), "intranet.corp.example:8080" or a pattern with a trailing space is always false. The rule the author wanted silently does not exist. Port and path decisions must be made on url, and even there with care (PAC-X008).

How to fix

Strip the path/port from the host pattern, or move the check to url with a pattern anchored at scheme and path.

Examples

Bad

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

Good

function FindProxyForURL(url, host) {
  if (host == "intranet.corp.example") {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open good example in checker

Related rules

References