Clear M1 milestone bugs (T-37, T-39, T-41, T-42, T-44, T-45, T-46, T-48, T-49, T-51, T-52)
This commit is contained in:
parent
199f7beecd
commit
9e259ca43b
18 changed files with 255 additions and 34 deletions
|
|
@ -122,8 +122,30 @@ function parseNumericIpv4Octets(host: string): [number, number, number, number]
|
|||
return [p0, p1, p2, p3];
|
||||
}
|
||||
|
||||
function isIpv4Loopback(host: string): boolean {
|
||||
const octets = parseNumericIpv4Octets(host);
|
||||
function parseDecimalIpv4Octets(host: string): [number, number, number, number] | null {
|
||||
const octets = host.split('.');
|
||||
if (octets.length !== 4) {
|
||||
return null;
|
||||
}
|
||||
const values: number[] = [];
|
||||
for (const part of octets) {
|
||||
if (!/^\d+$/.test(part)) {
|
||||
return null;
|
||||
}
|
||||
const value = Number(part);
|
||||
if (!Number.isSafeInteger(value) || value < 0 || value > 255) {
|
||||
return null;
|
||||
}
|
||||
values.push(value);
|
||||
}
|
||||
const [a, b, c, d] = values;
|
||||
if (a === undefined || b === undefined || c === undefined || d === undefined) {
|
||||
return null;
|
||||
}
|
||||
return [a, b, c, d];
|
||||
}
|
||||
|
||||
function isIpv4LoopbackOctets(octets: [number, number, number, number] | null): boolean {
|
||||
return (
|
||||
octets !== null &&
|
||||
(octets[0] === 127 ||
|
||||
|
|
@ -131,6 +153,16 @@ function isIpv4Loopback(host: string): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
function isIpv4Loopback(host: string): boolean {
|
||||
// Check both POSIX numeric IPv4 (octal/hex/shorthand, e.g. 0177.0.0.1, 127.1, 0x7f000001)
|
||||
// and decimal dotted-quad interpretation (e.g. 0127.0.0.1 -> 127.0.0.1) so resolvers that
|
||||
// read leading-zero quads as decimal cannot bypass the loopback guard.
|
||||
return (
|
||||
isIpv4LoopbackOctets(parseNumericIpv4Octets(host)) ||
|
||||
isIpv4LoopbackOctets(parseDecimalIpv4Octets(host))
|
||||
);
|
||||
}
|
||||
|
||||
function parseIpv6Side(side: string, allowIpv4Tail: boolean): number[] | null {
|
||||
if (side === '') {
|
||||
return [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue