mirror of
https://github.com/actions/setup-java.git
synced 2026-10-17 20:03:05 +01:00
Reject Maven mirrors missing selectors after URL authorities
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 59df028a-0d1b-49cb-8126-ab26408663e4
This commit is contained in:
13
src/auth.ts
13
src/auth.ts
@@ -355,12 +355,15 @@ export function parseMavenMirrors(entries: string[]): MavenMirror[] {
|
||||
|
||||
const separator = entry.indexOf(':');
|
||||
const remainder = entry.slice(separator + 1).trim();
|
||||
// Consume the URL scheme before looking for the selector delimiter. Selector
|
||||
// tokens may themselves contain colons (external:* and external:http:*).
|
||||
const scheme = /^[A-Za-z][A-Za-z0-9+.-]*:/.exec(remainder)?.[0] ?? '';
|
||||
// Protect scheme/authority colons (including IPv6 and ports) before
|
||||
// finding the selector, which may itself contain external:http:*.
|
||||
const urlPrefix =
|
||||
/^[A-Za-z][A-Za-z0-9+.-]*:(?:\/\/(?:[^/?#@\s]*@)?(?:\[[^\]]+\]|[^:/?#\s]+)(?::\d+(?=[/?#:\s]|$))?)?/.exec(
|
||||
remainder
|
||||
)?.[0] ?? '';
|
||||
const fields =
|
||||
/^(.*?):((?:\s*!?external:(?:http:)?\*\s*|[^:,]*)(?:,(?:\s*!?external:(?:http:)?\*\s*|[^:,]*))*)$/.exec(
|
||||
remainder.slice(scheme.length)
|
||||
remainder.slice(urlPrefix.length)
|
||||
);
|
||||
if (separator < 0 || !fields) {
|
||||
throw new Error(
|
||||
@@ -369,7 +372,7 @@ export function parseMavenMirrors(entries: string[]): MavenMirror[] {
|
||||
}
|
||||
|
||||
const id = entry.slice(0, separator).trim();
|
||||
const url = `${scheme}${fields[1]}`.trim();
|
||||
const url = `${urlPrefix}${fields[1]}`.trim();
|
||||
const mirrorOf = fields[2].trim();
|
||||
if (!id || !url || !mirrorOf) {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user