PAC-E014 · non-ascii-characters

Non-ASCII characters in code

high · Errors and robustness

The file contains characters outside 7-bit ASCII in code position, typically smart quotes from a word processor or a stray emoji. Smart quotes are a syntax error; other characters are at best unnecessary.

Why it matters

Everything a PAC needs (hostnames, IP literals, proxy directives) is ASCII. Non-ASCII characters appear through copy-paste from Word, Pages, mail clients or chat tools, which replace " with U+201C/U+201D. Those are not string delimiters in JavaScript, so the file does not parse and the client goes DIRECT. Characters inside comments are harmless to the parser but indicate the same editing tool chain. Internationalised host names must be written in their ASCII (punycode) form, because that is what Chrome, Edge, Firefox and Windows (WinHTTP and WinINet) pass in host, in lower case: bücher.example and BÜCHER.example both arrive as xn--bcher-kva.example, and BÜCHER.Corp.Example as xn--bcher-kva.corp.example (lab, 2026-10-15). shExpMatch(host, "*bücher*") is therefore false in every browser, while shExpMatch(host, "*xn--bcher-kva*") matches. Only pactester passes the host as you type it, so a test there can match where no browser does.

How to fix

Replace smart quotes with ASCII quotes, remove other non-ASCII characters; verify with `LC_ALL=C grep -nP '[^\x00-\x7F]' file`.

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) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open good example in checker

Engine behaviour

EngineBehaviourSource
chromiumA non-ASCII string returned by FindProxyForURL is rejected as a script error ("returned a non-ASCII string"); non-ASCII inside string literals that are not returned is not an error. An internationalised host arrives in lower-case punycode (BÜCHER-Case.example.test as xn--bcher-case-9db.example.test), in host and in url (lab 2026-10-15, Chrome 155, Edge 155, Chromium 145; url/url_canon_host.cc DoIdnHost).code, verified 2026-10-04 · ref
firefoxAn internationalised host arrives in lower-case punycode (BÜCHER-Case.example.test as xn--bcher-case-9db.example.test), in host and in url. In the source, netwerk/base/nsPACMan.cpp takes GetAsciiHost() and GetAsciiSpec().lab, verified 2026-10-15
winhttpAn internationalised host arrives in lower-case punycode, in host and in url, although WinHTTP keeps the case of plain ASCII host names. The other labels of such a name are lower-cased too (BÜCHER-Case.Example.test arrives as xn--bcher-case-9db.example.test).lab, verified 2026-10-15
wininetAn internationalised host arrives in lower-case punycode, in host and in url, also with capitals in the other labels; measured both with a direct proxy query and with real requests of a WinINet program.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.

Related rules

References

Last updated: