PAC-C018 · uppercase-pattern-literal

Upper-case letters in a hostname pattern

medium · Correctness · Top 20 #20

Browsers hand the PAC a lower-cased hostname, so a pattern such as "Intranet.Corp.Example" never matches in Chromium or Firefox. Where the host keeps its case (Windows programs using WinHTTP, such as BITS), comparisons are case-sensitive, so write patterns in lower case and lower-case host.

Why it matters

URL parsing in Chromium and Firefox follows the URL Standard, which lower-cases ASCII domain names, so host arrives lower-cased and the pattern must be lower-case to match (measured in Chrome, Edge and Firefox, lab 2026-10-15). On Windows, programs that use WinHTTP (system services, BITS) pass the hostname with the case the program used, while WinINet, .NET and Java programs lower-case it (lab, 2026-10-11). In the WinHTTP case the same upper-case pattern matches only if the name was written that way, and dnsDomainIs and shExpMatch compare case-sensitively there. The robust idiom is to lower-case both sides: host = host.toLowerCase(); at the top of the function and lower-case literals everywhere (PAC-K009). Mixed-case literals are therefore always wrong.

How to fix

Write all hostname literals in lower case and add host = host.toLowerCase(); at the start of the function.

Examples

Bad

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

Good

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

Engine behaviour

EngineBehaviourSource
chromiumThe host is passed lower-cased (Case-Http.Example.COM arrives as case-http.example.com, FD00::A1 as fd00::a1). The host part of url is lower-cased too; the path keeps its case. In the source, services/proxy_resolver/proxy_resolver_v8.cc passes the canonical URL's HostNoBrackets().lab, verified 2026-10-15
firefoxThe host is passed lower-cased (Case-Http.Example.COM arrives as case-http.example.com, FD00::A1 as fd00::a1), and so is the host part of url. In the source, netwerk/base/nsPACMan.cpp takes the normalised URI's GetAsciiHost().lab, verified 2026-10-15
pacparserPasses host as given; dnsDomainIs(host, ".example.com") does not match "Example.com".lab, verified 2026-05-20
winhttphost keeps its case (Example.COM arrives as Example.COM, also from BITS). dnsDomainIs and shExpMatch compare case-sensitively; localHostOrDomainIs ignores case.lab, verified 2026-10-11
wininetPrograms using WinINet, .NET Framework, .NET 8 and Java passed the host lower-cased, and the host part of url too; the path keeps its case. An IPv6 address keeps its letters ([FD00::A1] stays [FD00::A1]).lab, verified 2026-10-15

Source: code = read in the engine's source, doc = vendor documentation, lab = observed in a lab run, expert = practitioner knowledge, not yet verified.

The PAC functions this rule is about

  • dnsDomainIs(): True if host ends with domain. A plain string suffix comparison, no DNS lookup.

Related rules

References

Last updated: