From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4251: OAuth implementation
Date: Wed, 09 Sep 2026 15:45:37 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4251-rc3970363394@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4251@github.com>
References: <gh-pgjdbc-pgjdbc-4251@github.com>
(on pgjdbc/src/test/java/org/postgresql/core/v3/BuildTokenMessageTest.java)
Good set of invalid characters. Five cases are missing at the boundary of `[A-Za-z0-9._~+/-]+=*`, and this regex is the only thing standing between a caller and a malformed token on the wire:
- `"="` alone, padding with no leading character, which the `+` refuses
- `"abc=def"`, an `=` in the middle
- `"abc=="`, double padding, since only a single `=` is covered today
- `"a"`, one character
- a non-ASCII token. This one is not cosmetic: `buildTokenMessage` writes the token with `msg.put((byte) c)`, and that narrowing is safe only because the regex ran first. Nothing pins that ordering.
`@ValueSource` also prints the argument as the case name, so `"newline\nhere"` puts a real line break into the report and `"soh\u0001here"` puts a control byte into the XML. `@MethodSource` with `argumentSet("token containing a newline", "newline\nhere")` names them instead.
Minor: `validToken` asserts on the decoded `String` and reads well on failure, while `nullToken` and `emptyToken` assert on raw bytes and print `expected: <[110, 44, 44, 1, ...]>`. One style for both would help.