PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/modules/abilities/index.js +413 -130 23.9.0 → 24.1.0 View file →
@@ -3117,11 +3117,30 @@
3117 3117 "node_modules/fast-uri/lib/utils.js"(exports, module) {
3118 3118 "use strict";
3119 3119 var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3120 3120 var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3121 + var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3121 3122 var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3122 3123 var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3123 - var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3124 + var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3125 + var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3126 + var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3127 + var BYTE_HEX = new Array(256);
3128 + {
3129 + const HEX_DIGITS = "0123456789ABCDEF";
3130 + for (let i = 0; i < 256; i++) {
3131 + BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
3132 + }
3133 + }
3134 + function percentEncodeNonAscii(cp) {
3135 + if (cp < 2048) {
3136 + return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
3137 + }
3138 + if (cp < 65536) {
3139 + return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3140 + }
3141 + return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3142 + }
3124 3143 function stringArrayToHexStripped(input) {
3125 3144 let acc = "";
3126 3145 let code = 0;
3127 3146 let i = 0;
@@ -3144,93 +3163,107 @@
3144 3163 acc += input[i];
3145 3164 }
3146 3165 return acc;
3147 3166 }
3167 + var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3168 + var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3169 + var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3148 3170 var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3149 - function consumeIsZone(buffer) {
3150 - buffer.length = 0;
3171 + function isZoneIdentifier(zone) {
3172 + if (zone.length === 0) return false;
3173 + for (let i = 0; i < zone.length; i++) {
3174 + if (isZoneCharacter(zone[i])) continue;
3175 + if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3176 + i += 2;
3177 + continue;
3178 + }
3179 + return false;
3180 + }
3151 3181 return true;
3152 3182 }
3153 - function consumeHextets(buffer, address, output) {
3154 - if (buffer.length) {
3155 - const hex = stringArrayToHexStripped(buffer);
3156 - if (hex !== "") {
3157 - address.push(hex);
3183 + function compressIPv6ZeroRun(hextets) {
3184 + let bestStart = -1;
3185 + let bestLength = 0;
3186 + let runStart = -1;
3187 + let runLength = 0;
3188 + for (let i = 0; i < hextets.length; i++) {
3189 + if (hextets[i] === "0") {
3190 + if (runStart === -1) runStart = i;
3191 + runLength++;
3192 + if (runLength > bestLength) {
3193 + bestLength = runLength;
3194 + bestStart = runStart;
3195 + }
3158 3196 } else {
3159 - output.error = true;
3160 - return false;
3197 + runStart = -1;
3198 + runLength = 0;
3161 3199 }
3162 - buffer.length = 0;
3163 3200 }
3164 - return true;
3201 + if (bestLength < 2) return hextets.join(":");
3202 + const head = hextets.slice(0, bestStart).join(":");
3203 + const tail = hextets.slice(bestStart + bestLength).join(":");
3204 + return head + "::" + tail;
3165 3205 }
3166 - function getIPV6(input) {
3167 - let tokenCount = 0;
3168 - const output = { error: false, address: "", zone: "" };
3169 - const address = [];
3170 - const buffer = [];
3171 - let endipv6Encountered = false;
3172 - let endIpv6 = false;
3173 - let consume = consumeHextets;
3174 - for (let i = 0; i < input.length; i++) {
3175 - const cursor = input[i];
3176 - if (cursor === "[" || cursor === "]") {
3206 + function normalizeIPv6Address(input) {
3207 + const compression = input.indexOf("::");
3208 + if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
3209 + const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3210 + const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3211 + if (compression !== -1) {
3212 + if (left.length === 1 && left[0] === "") left.length = 0;
3213 + if (right.length === 1 && right[0] === "") right.length = 0;
3214 + }
3215 + const parts = left.concat(right);
3216 + let hextetCount = 0;
3217 + for (let i = 0; i < parts.length; i++) {
3218 + const part = parts[i];
3219 + if (part === "") return void 0;
3220 + if (part.indexOf(".") !== -1) {
3221 + if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
3222 + hextetCount += 2;
3177 3223 continue;
3178 3224 }
3179 - if (cursor === ":") {
3180 - if (endipv6Encountered === true) {
3181 - endIpv6 = true;
3182 - }
3183 - if (!consume(buffer, address, output)) {
3184 - break;
3185 - }
3186 - if (++tokenCount > 7) {
3187 - output.error = true;
3188 - break;
3189 - }
3190 - if (i > 0 && input[i - 1] === ":") {
3191 - endipv6Encountered = true;
3192 - }
3193 - address.push(":");
3194 - continue;
3195 - } else if (cursor === "%") {
3196 - if (!consume(buffer, address, output)) {
3197 - break;
3198 - }
3199 - consume = consumeIsZone;
3200 - } else {
3201 - buffer.push(cursor);
3202 - continue;
3203 - }
3225 + if (!isHextet(part)) return void 0;
3226 + parts[i] = parseInt(part, 16).toString(16);
3227 + hextetCount++;
3204 3228 }
3205 - if (buffer.length) {
3206 - if (consume === consumeIsZone) {
3207 - output.zone = buffer.join("");
3208 - } else if (endIpv6) {
3209 - address.push(buffer.join(""));
3210 - } else {
3211 - address.push(stringArrayToHexStripped(buffer));
3212 - }
3229 + if (compression === -1) {
3230 + if (hextetCount !== 8) return void 0;
3231 + return compressIPv6ZeroRun(parts);
3213 3232 }
3214 - output.address = address.join("");
3215 - return output;
3233 + if (hextetCount >= 8) return void 0;
3234 + const expanded = parts.slice(0, left.length);
3235 + for (let i = hextetCount; i < 8; i++) expanded.push("0");
3236 + for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
3237 + return compressIPv6ZeroRun(expanded);
3216 3238 }
3217 3239 function normalizeIPv6(host) {
3218 - if (findToken(host, ":") < 2) {
3219 - return { host, isIPV6: false };
3240 + const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3241 + const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3242 + if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
3243 + let input = bracketed ? host.slice(1, -1) : host;
3244 + if (bracketed && isIPvFuture(input)) {
3245 + input = input.toLowerCase();
3246 + return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3220 3247 }
3221 - const ipv6 = getIPV6(host);
3222 - if (!ipv6.error) {
3223 - let newHost = ipv6.address;
3224 - let escapedHost = ipv6.address;
3225 - if (ipv6.zone) {
3226 - newHost += "%" + ipv6.zone;
3227 - escapedHost += "%25" + ipv6.zone;
3228 - }
3229 - return { host: newHost, isIPV6: true, escapedHost };
3230 - } else {
3231 - return { host, isIPV6: false };
3248 + if (findToken(input, ":") < 2) {
3249 + return { host, isIPV6: false, error: bracketed };
3232 3250 }
3251 + let zoneIdentifier = "";
3252 + const zoneSeparator = input.indexOf("%");
3253 + if (zoneSeparator !== -1) {
3254 + const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3255 + zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3256 + if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
3257 + input = input.slice(0, zoneSeparator);
3258 + }
3259 + const address = normalizeIPv6Address(input);
3260 + if (address === void 0) return { host, isIPV6: false, error: true };
3261 + return {
3262 + host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3263 + escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3264 + isIPV6: true
3265 + };
3233 3266 }
3234 3267 function findToken(str, token) {
3235 3268 let ind = 0;
3236 3269 for (let i = 0; i < str.length; i++) {
@@ -3347,9 +3380,10 @@
3347 3380 }
3348 3381 function normalizePathEncoding(input) {
3349 3382 let output = "";
3350 3383 for (let i = 0; i < input.length; i++) {
3351 - if (input[i] === "%" && i + 2 < input.length) {
3384 + const ch = input[i];
3385 + if (ch === "%" && i + 2 < input.length) {
3352 3386 const hex = input.slice(i + 1, i + 3);
3353 3387 if (isHexPair(hex)) {
3354 3388 const normalizedHex = hex.toUpperCase();
3355 3389 const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
@@ -3361,16 +3395,158 @@
3361 3395 i += 2;
3362 3396 continue;
3363 3397 }
3364 3398 }
3365 - if (isPathCharacter(input[i])) {
3366 - output += input[i];
3399 + if (isPathCharacter(ch)) {
3400 + output += ch;
3367 3401 } else {
3368 - output += escape(input[i]);
3402 + const code = input.charCodeAt(i);
3403 + if (code < 128) {
3404 + output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3405 + } else if (code < 55296 || code > 57343) {
3406 + output += percentEncodeNonAscii(code);
3407 + } else if (code <= 56319 && i + 1 < input.length) {
3408 + const low = input.charCodeAt(i + 1);
3409 + if (low >= 56320 && low <= 57343) {
3410 + output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3411 + i++;
3412 + } else {
3413 + output += percentEncodeNonAscii(65533);
3414 + }
3415 + } else {
3416 + output += percentEncodeNonAscii(65533);
3417 + }
3369 3418 }
3370 3419 }
3371 3420 return output;
3372 3421 }
3422 + function serializePathEncoding(input, pathNoScheme = false) {
3423 + let output = "";
3424 + let firstSegment = pathNoScheme && input[0] !== "/";
3425 + for (let i = 0; i < input.length; i++) {
3426 + const ch = input[i];
3427 + if (ch === "%" && i + 2 < input.length) {
3428 + const hex = input.slice(i + 1, i + 3);
3429 + if (isHexPair(hex)) {
3430 + output += "%" + hex.toUpperCase();
3431 + i += 2;
3432 + continue;
3433 + }
3434 + }
3435 + if (ch === "/") {
3436 + firstSegment = false;
3437 + }
3438 + if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3439 + output += ch;
3440 + } else {
3441 + const code = input.charCodeAt(i);
3442 + if (code < 128) {
3443 + output += BYTE_HEX[code];
3444 + } else if (code < 55296 || code > 57343) {
3445 + output += percentEncodeNonAscii(code);
3446 + } else if (code <= 56319 && i + 1 < input.length) {
3447 + const low = input.charCodeAt(i + 1);
3448 + if (low >= 56320 && low <= 57343) {
3449 + output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3450 + i++;
3451 + } else {
3452 + output += percentEncodeNonAscii(65533);
3453 + }
3454 + } else {
3455 + output += percentEncodeNonAscii(65533);
3456 + }
3457 + }
3458 + }
3459 + return output;
3460 + }
3461 + function encodeComponent(input, isAllowed) {
3462 + let output = "";
3463 + for (let i = 0; i < input.length; i++) {
3464 + const ch = input[i];
3465 + if (ch === "%" && i + 2 < input.length) {
3466 + const hex = input.slice(i + 1, i + 3);
3467 + if (isHexPair(hex)) {
3468 + output += "%" + hex.toUpperCase();
3469 + i += 2;
3470 + continue;
3471 + }
3472 + }
3473 + if (isAllowed(ch)) {
3474 + output += ch;
3475 + } else {
3476 + const code = input.charCodeAt(i);
3477 + if (code < 128) {
3478 + output += BYTE_HEX[code];
3479 + } else if (code < 55296 || code > 57343) {
3480 + output += percentEncodeNonAscii(code);
3481 + } else if (code <= 56319 && i + 1 < input.length) {
3482 + const low = input.charCodeAt(i + 1);
3483 + if (low >= 56320 && low <= 57343) {
3484 + output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3485 + i++;
3486 + } else {
3487 + output += percentEncodeNonAscii(65533);
3488 + }
3489 + } else {
3490 + output += percentEncodeNonAscii(65533);
3491 + }
3492 + }
3493 + }
3494 + return output;
3495 + }
3496 + function encodeUserinfo(input) {
3497 + return encodeComponent(input, isUserinfoCharacter);
3498 + }
3499 + function encodeQuery(input) {
3500 + return encodeComponent(input, isQueryFragmentCharacter);
3501 + }
3502 + function encodeFragment(input) {
3503 + return encodeComponent(input, isQueryFragmentCharacter);
3504 + }
3505 + function isEscapeSafe(cp) {
3506 + return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
3507 + }
3508 + function normalizeQueryFragmentEncoding(input) {
3509 + let output = "";
3510 + for (let i = 0; i < input.length; i++) {
3511 + const ch = input[i];
3512 + if (ch === "%" && i + 2 < input.length) {
3513 + const hex = input.slice(i + 1, i + 3);
3514 + if (isHexPair(hex)) {
3515 + const normalizedHex = hex.toUpperCase();
3516 + const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3517 + if (isUnreserved(decoded)) {
3518 + output += decoded;
3519 + } else {
3520 + output += "%" + normalizedHex;
3521 + }
3522 + i += 2;
3523 + continue;
3524 + }
3525 + }
3526 + if (isQueryFragmentCharacter(ch)) {
3527 + output += ch;
3528 + } else {
3529 + const code = input.charCodeAt(i);
3530 + if (code < 128) {
3531 + output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3532 + } else if (code < 55296 || code > 57343) {
3533 + output += percentEncodeNonAscii(code);
3534 + } else if (code <= 56319 && i + 1 < input.length) {
3535 + const low = input.charCodeAt(i + 1);
3536 + if (low >= 56320 && low <= 57343) {
3537 + output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3538 + i++;
3539 + } else {
3540 + output += percentEncodeNonAscii(65533);
3541 + }
3542 + } else {
3543 + output += percentEncodeNonAscii(65533);
3544 + }
3545 + }
3546 + }
3547 + return output;
3548 + }
3373 3549 function escapePreservingEscapes(input) {
3374 3550 let output = "";
3375 3551 for (let i = 0; i < input.length; i++) {
3376 3552 if (input[i] === "%" && i + 2 < input.length) {
@@ -3387,16 +3563,20 @@
3387 3563 }
3388 3564 function recomposeAuthority(component) {
3389 3565 const uriTokens = [];
3390 3566 if (component.userinfo !== void 0) {
3391 - uriTokens.push(component.userinfo);
3567 + uriTokens.push(encodeUserinfo(component.userinfo));
3392 3568 uriTokens.push("@");
3393 3569 }
3394 3570 if (component.host !== void 0) {
3395 - let host = unescape(component.host);
3571 + let host = component.host;
3396 3572 if (!isIPv4(host)) {
3397 - const ipV6res = normalizeIPv6(host);
3398 - if (ipV6res.isIPV6 === true) {
3573 + let ipV6res = normalizeIPv6(host);
3574 + if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3575 + host = normalizePercentEncoding(host, true);
3576 + ipV6res = normalizeIPv6(host);
3577 + }
3578 + if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3399 3579 host = `[${ipV6res.escapedHost}]`;
3400 3580 } else {
3401 3581 host = reescapeHostDelimiters(host, false);
3402 3582 }
@@ -3403,10 +3583,14 @@
3403 3583 }
3404 3584 uriTokens.push(host);
3405 3585 }
3406 3586 if (typeof component.port === "number" || typeof component.port === "string") {
3587 + const port = String(component.port);
3588 + if (!isPort(port)) {
3589 + throw new TypeError("URI port is malformed.");
3590 + }
3407 3591 uriTokens.push(":");
3408 - uriTokens.push(String(component.port));
3592 + uriTokens.push(port);
3409 3593 }
3410 3594 return uriTokens.length ? uriTokens.join("") : void 0;
3411 3595 }
3412 3596 module.exports = {
@@ -3414,8 +3598,13 @@
3414 3598 recomposeAuthority,
3415 3599 reescapeHostDelimiters,
3416 3600 normalizePercentEncoding,
3417 3601 normalizePathEncoding,
3602 + serializePathEncoding,
3603 + normalizeQueryFragmentEncoding,
3604 + encodeUserinfo,
3605 + encodeQuery,
3606 + encodeFragment,
3418 3607 escapePreservingEscapes,
3419 3608 removeDotSegments,
3420 3609 isIPv4,
3421 3610 isUUID,
@@ -3429,9 +3618,9 @@
3429 3618 var require_schemes = __commonJS({
3430 3619 "node_modules/fast-uri/lib/schemes.js"(exports, module) {
3431 3620 "use strict";
3432 3621 var { isUUID } = require_utils();
3433 - var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3622 + var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3434 3623 var supportedSchemeNames = (
3435 3624 /** @type {const} */
3436 3625 [
3437 3626 "http",
@@ -3490,11 +3679,12 @@
3490 3679 wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
3491 3680 wsComponent.secure = void 0;
3492 3681 }
3493 3682 if (wsComponent.resourceName) {
3494 - const [path, query] = wsComponent.resourceName.split("?");
3683 + const queryIndex = wsComponent.resourceName.indexOf("?");
3684 + const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3495 3685 wsComponent.path = path && path !== "/" ? path : void 0;
3496 - wsComponent.query = query;
3686 + wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3497 3687 wsComponent.resourceName = void 0;
3498 3688 }
3499 3689 wsComponent.fragment = void 0;
3500 3690 return wsComponent;
@@ -3504,9 +3694,9 @@
3504 3694 urnComponent.error = "URN can not be parsed";
3505 3695 return urnComponent;
3506 3696 }
3507 3697 const matches = urnComponent.path.match(URN_REG);
3508 - if (matches) {
3698 + if (matches && matches[0] === urnComponent.path) {
3509 3699 const scheme = options.scheme || urnComponent.scheme || "urn";
3510 3700 urnComponent.nid = matches[1].toLowerCase();
3511 3701 urnComponent.nss = matches[2];
3512 3702 const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
@@ -3638,10 +3828,19 @@
3638 3828 // node_modules/fast-uri/index.js
3639 3829 var require_fast_uri = __commonJS({
3640 3830 "node_modules/fast-uri/index.js"(exports, module) {
3641 3831 "use strict";
3642 - var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3832 + var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3643 3833 var { SCHEMES, getSchemeHandler } = require_schemes();
3834 + var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3835 + var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3836 + function decodeValidScheme(scheme) {
3837 + const decodedScheme = unescape(String(scheme));
3838 + if (!VALID_SCHEME.test(decodedScheme)) {
3839 + throw new TypeError(MALFORMED_SCHEME_ERROR);
3840 + }
3841 + return decodedScheme;
3842 + }
3644 3843 function normalize(uri, options) {
3645 3844 if (typeof uri === "string") {
3646 3845 uri = /** @type {T} */
3647 3846 normalizeString(uri, options);
@@ -3652,14 +3851,36 @@
3652 3851 return uri;
3653 3852 }
3654 3853 function resolve(baseURI, relativeURI, options) {
3655 3854 const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3656 - const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3657 - const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3658 - if (baseMalformed || relativeMalformed) {
3855 + const {
3856 + parsed: baseParsed,
3857 + malformedAuthorityOrPort: baseMalformed,
3858 + malformedPercentEncoding: baseMalformedPercentEncoding,
3859 + malformedSchemeSpecific: baseMalformedSchemeSpecific,
3860 + malformedHost: baseMalformedHost,
3861 + malformedScheme: baseMalformedScheme
3862 + } = parseWithStatus(baseURI, schemelessOptions);
3863 + const {
3864 + parsed: relativeParsed,
3865 + malformedAuthorityOrPort: relativeMalformed,
3866 + malformedPercentEncoding: relativeMalformedPercentEncoding,
3867 + malformedSchemeSpecific: relativeMalformedSchemeSpecific,
3868 + malformedHost: relativeMalformedHost,
3869 + malformedScheme: relativeMalformedScheme
3870 + } = parseWithStatus(relativeURI, schemelessOptions);
3871 + if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3659 3872 throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3660 3873 }
3661 3874 const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3875 + const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3876 + const resolvedHost = resolved.host;
3877 + const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3878 + canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3879 + const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3880 + if (resolved.error && !encodedASCIIHost) {
3881 + throw new Error(resolved.error);
3882 + }
3662 3883 schemelessOptions.skipEscape = true;
3663 3884 return serialize(resolved, schemelessOptions);
3664 3885 }
3665 3886 function resolveComponent(base, relative, options, skipNormalization) {
@@ -3717,9 +3938,9 @@
3717 3938 }
3718 3939 function equal(uriA, uriB, options) {
3719 3940 const normalizedA = normalizeComparableURI(uriA, options);
3720 3941 const normalizedB = normalizeComparableURI(uriB, options);
3721 - return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3942 + return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3722 3943 }
3723 3944 function serialize(cmpts, opts) {
3724 3945 const component = {
3725 3946 host: cmpts.host,
@@ -3738,21 +3959,24 @@
3738 3959 error: ""
3739 3960 };
3740 3961 const options = Object.assign({}, opts);
3741 3962 const uriTokens = [];
3963 + if (component.scheme) {
3964 + component.scheme = decodeValidScheme(component.scheme);
3965 + }
3742 3966 const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3743 3967 if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3968 + const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3969 + const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
3744 3970 if (component.path !== void 0) {
3745 3971 if (!options.skipEscape) {
3746 - component.path = escapePreservingEscapes(component.path);
3747 - if (component.scheme !== void 0) {
3748 - component.path = component.path.split("%3A").join(":");
3749 - }
3972 + component.path = serializePathEncoding(component.path, pathNoScheme);
3750 3973 } else {
3751 3974 component.path = normalizePercentEncoding(component.path);
3752 3975 }
3753 3976 }
3754 3977 if (options.reference !== "suffix" && component.scheme) {
3978 + component.scheme = decodeValidScheme(component.scheme);
3755 3979 uriTokens.push(component.scheme, ":");
3756 3980 }
3757 3981 const authority = recomposeAuthority(component);
3758 3982 if (authority !== void 0) {
@@ -3768,8 +3992,11 @@
3768 3992 let s = component.path;
3769 3993 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3770 3994 s = removeDotSegments(s);
3771 3995 }
3996 + if (pathNoScheme) {
3997 + s = serializePathEncoding(s, true);
3998 + }
3772 3999 if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3773 4000 s = "/%2F" + s.slice(2);
3774 4001 }
3775 4002 uriTokens.push(s);
@@ -3774,12 +4001,12 @@
3774 4001 }
3775 4002 uriTokens.push(s);
3776 4003 }
3777 4004 if (component.query !== void 0) {
3778 - uriTokens.push("?", component.query);
4005 + uriTokens.push("?", encodeQuery(component.query));
3779 4006 }
3780 4007 if (component.fragment !== void 0) {
3781 - uriTokens.push("#", component.fragment);
4008 + uriTokens.push("#", encodeFragment(component.fragment));
3782 4009 }
3783 4010 return uriTokens.join("");
3784 4011 }
3785 4012 var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
@@ -3793,8 +4020,37 @@
3793 4020 return "URI port is malformed.";
3794 4021 }
3795 4022 return void 0;
3796 4023 }
4024 + function hasMalformedPercentEncoding(component) {
4025 + if (component === void 0) return false;
4026 + let percent = component.indexOf("%");
4027 + while (percent !== -1) {
4028 + if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4029 + return true;
4030 + }
4031 + percent = component.indexOf("%", percent + 3);
4032 + }
4033 + return false;
4034 + }
4035 + function isIPLiteral(host) {
4036 + return host[0] === "[" && host[host.length - 1] === "]";
4037 + }
4038 + function hasMalformedComponentPercentEncoding(matches) {
4039 + const host = matches[4];
4040 + return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4041 + }
4042 + function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4043 + if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4044 + try {
4045 + parsed.host = new URL("http://" + parsed.host).hostname;
4046 + } catch (e) {
4047 + parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4048 + return true;
4049 + }
4050 + }
4051 + return false;
4052 + }
3797 4053 function parseWithStatus(uri, opts) {
3798 4054 const options = Object.assign({}, opts);
3799 4055 const parsed = {
3800 4056 scheme: void 0,
@@ -3805,8 +4061,13 @@
3805 4061 query: void 0,
3806 4062 fragment: void 0
3807 4063 };
3808 4064 let malformedAuthorityOrPort = false;
4065 + let malformedPercentEncoding = false;
4066 + let malformedSchemeSpecific = false;
4067 + let malformedHost = false;
4068 + let malformedIPLiteral = false;
4069 + let malformedScheme = false;
3809 4070 let isIP = false;
3810 4071 if (options.reference === "suffix") {
3811 4072 if (options.scheme) {
3812 4073 uri = options.scheme + ":" + uri;
@@ -3841,8 +4102,21 @@
3841 4102 parsed.port = parseInt(matches[5], 10);
3842 4103 parsed.path = matches[6] || "";
3843 4104 parsed.query = matches[7];
3844 4105 parsed.fragment = matches[8];
4106 + if (parsed.scheme !== void 0) {
4107 + const decodedScheme = unescape(parsed.scheme);
4108 + if (VALID_SCHEME.test(decodedScheme)) {
4109 + parsed.scheme = decodedScheme.toLowerCase();
4110 + } else {
4111 + parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4112 + malformedScheme = true;
4113 + }
4114 + }
4115 + malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4116 + if (malformedPercentEncoding) {
4117 + parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4118 + }
3845 4119 if (isNaN(parsed.port)) {
3846 4120 parsed.port = matches[5];
3847 4121 }
3848 4122 const parseError = getParseError(parsed, matches);
@@ -3852,11 +4126,18 @@
3852 4126 }
3853 4127 if (parsed.host) {
3854 4128 const ipv4result = isIPv4(parsed.host);
3855 4129 if (ipv4result === false) {
4130 + const bracketedIPLiteral = isIPLiteral(parsed.host);
4131 + const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3856 4132 const ipv6result = normalizeIPv6(parsed.host);
3857 - parsed.host = ipv6result.host.toLowerCase();
3858 - isIP = ipv6result.isIPV6;
4133 + isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4134 + malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4135 + parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4136 + if (malformedIPLiteral) {
4137 + parsed.error = parsed.error || "URI host is malformed.";
4138 + malformedAuthorityOrPort = true;
4139 + }
3859 4140 } else {
3860 4141 isIP = true;
3861 4142 }
3862 4143 }
@@ -3872,44 +4153,38 @@
3872 4153 if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
3873 4154 parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3874 4155 }
3875 4156 const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3876 - if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3877 - if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3878 - try {
3879 - parsed.host = new URL("http://" + parsed.host).hostname;
3880 - } catch (e) {
3881 - parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3882 - }
3883 - }
4157 + if (!malformedIPLiteral) {
4158 + malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3884 4159 }
3885 4160 if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3886 4161 if (uri.indexOf("%") !== -1) {
3887 - if (parsed.scheme !== void 0) {
3888 - parsed.scheme = unescape(parsed.scheme);
4162 + if (parsed.host !== void 0 && !malformedIPLiteral) {
4163 + const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4164 + parsed.host = reescapeHostDelimiters(host, isIP);
3889 4165 }
3890 - if (parsed.host !== void 0) {
3891 - parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
3892 - }
3893 4166 }
3894 4167 if (parsed.path) {
3895 4168 parsed.path = normalizePathEncoding(parsed.path);
3896 4169 }
4170 + if (parsed.query) {
4171 + parsed.query = normalizeQueryFragmentEncoding(parsed.query);
4172 + }
3897 4173 if (parsed.fragment) {
3898 - try {
3899 - parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3900 - } catch {
3901 - parsed.error = parsed.error || "URI malformed";
3902 - }
4174 + parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3903 4175 }
3904 4176 }
3905 4177 if (schemeHandler && schemeHandler.parse) {
3906 4178 schemeHandler.parse(parsed, options);
4179 + if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4180 + malformedSchemeSpecific = true;
4181 + }
3907 4182 }
3908 4183 } else {
3909 4184 parsed.error = parsed.error || "URI can not be parsed.";
3910 4185 }
3911 - return { parsed, malformedAuthorityOrPort };
4186 + return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3912 4187 }
3913 4188 function parse(uri, opts) {
3914 4189 return parseWithStatus(uri, opts).parsed;
3915 4190 }
@@ -3916,22 +4191,30 @@
3916 4191 function normalizeString(uri, opts) {
3917 4192 return normalizeStringWithStatus(uri, opts).normalized;
3918 4193 }
3919 4194 function normalizeStringWithStatus(uri, opts) {
3920 - const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4195 + const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3921 4196 return {
3922 - normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3923 - malformedAuthorityOrPort
4197 + normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4198 + malformedAuthorityOrPort,
4199 + malformedPercentEncoding,
4200 + malformedSchemeSpecific,
4201 + malformedHost,
4202 + malformedScheme
3924 4203 };
3925 4204 }
3926 4205 function normalizeComparableURI(uri, opts) {
3927 - if (typeof uri === "string") {
3928 - const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3929 - return malformedAuthorityOrPort ? void 0 : normalized;
4206 + if (typeof uri !== "string" && typeof uri !== "object") {
4207 + return void 0;
3930 4208 }
3931 - if (typeof uri === "object") {
3932 - return serialize(uri, opts);
4209 + let value;
4210 + try {
4211 + value = typeof uri === "string" ? uri : serialize(uri, opts);
4212 + } catch {
4213 + return void 0;
3933 4214 }
4215 + const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4216 + return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3934 4217 }
3935 4218 var fastUri = {
3936 4219 SCHEMES,
3937 4220 normalize,
@@ -6590,11 +6873,11 @@
6590 6873 } });
6591 6874 }
6592 6875 });
6593 6876
6594 -// packages/abilities/node_modules/ajv-formats/dist/formats.js
6877 +// node_modules/ajv-formats/dist/formats.js
6595 6878 var require_formats = __commonJS({
6596 - "packages/abilities/node_modules/ajv-formats/dist/formats.js"(exports) {
6879 + "node_modules/ajv-formats/dist/formats.js"(exports) {
6597 6880 "use strict";
6598 6881 Object.defineProperty(exports, "__esModule", { value: true });
6599 6882 exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
6600 6883 function fmtDef(validate, compare) {
@@ -7171,11 +7454,11 @@
7171 7454 } });
7172 7455 }
7173 7456 });
7174 7457
7175 -// packages/abilities/node_modules/ajv-formats/dist/limit.js
7458 +// node_modules/ajv-formats/dist/limit.js
7176 7459 var require_limit = __commonJS({
7177 - "packages/abilities/node_modules/ajv-formats/dist/limit.js"(exports) {
7460 + "node_modules/ajv-formats/dist/limit.js"(exports) {
7178 7461 "use strict";
7179 7462 Object.defineProperty(exports, "__esModule", { value: true });
7180 7463 exports.formatLimitDefinition = void 0;
7181 7464 var ajv_1 = require_ajv();
@@ -7243,11 +7526,11 @@
7243 7526 exports.default = formatLimitPlugin;
7244 7527 }
7245 7528 });
7246 7529
7247 -// packages/abilities/node_modules/ajv-formats/dist/index.js
7530 +// node_modules/ajv-formats/dist/index.js
7248 7531 var require_dist2 = __commonJS({
7249 - "packages/abilities/node_modules/ajv-formats/dist/index.js"(exports, module) {
7532 + "node_modules/ajv-formats/dist/index.js"(exports, module) {
7250 7533 "use strict";
7251 7534 Object.defineProperty(exports, "__esModule", { value: true });
7252 7535 var formats_1 = require_formats();
7253 7536 var limit_1 = require_limit();