PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
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 +437 -128 23.7.0 → trunk 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,9 +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 resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
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) {
3872 + throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3873 + }
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 + }
3657 3883 schemelessOptions.skipEscape = true;
3658 3884 return serialize(resolved, schemelessOptions);
3659 3885 }
3660 3886 function resolveComponent(base, relative, options, skipNormalization) {
@@ -3712,9 +3938,9 @@
3712 3938 }
3713 3939 function equal(uriA, uriB, options) {
3714 3940 const normalizedA = normalizeComparableURI(uriA, options);
3715 3941 const normalizedB = normalizeComparableURI(uriB, options);
3716 - return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3942 + return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3717 3943 }
3718 3944 function serialize(cmpts, opts) {
3719 3945 const component = {
3720 3946 host: cmpts.host,
@@ -3733,21 +3959,24 @@
3733 3959 error: ""
3734 3960 };
3735 3961 const options = Object.assign({}, opts);
3736 3962 const uriTokens = [];
3963 + if (component.scheme) {
3964 + component.scheme = decodeValidScheme(component.scheme);
3965 + }
3737 3966 const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3738 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;
3739 3970 if (component.path !== void 0) {
3740 3971 if (!options.skipEscape) {
3741 - component.path = escapePreservingEscapes(component.path);
3742 - if (component.scheme !== void 0) {
3743 - component.path = component.path.split("%3A").join(":");
3744 - }
3972 + component.path = serializePathEncoding(component.path, pathNoScheme);
3745 3973 } else {
3746 3974 component.path = normalizePercentEncoding(component.path);
3747 3975 }
3748 3976 }
3749 3977 if (options.reference !== "suffix" && component.scheme) {
3978 + component.scheme = decodeValidScheme(component.scheme);
3750 3979 uriTokens.push(component.scheme, ":");
3751 3980 }
3752 3981 const authority = recomposeAuthority(component);
3753 3982 if (authority !== void 0) {
@@ -3763,8 +3992,11 @@
3763 3992 let s = component.path;
3764 3993 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3765 3994 s = removeDotSegments(s);
3766 3995 }
3996 + if (pathNoScheme) {
3997 + s = serializePathEncoding(s, true);
3998 + }
3767 3999 if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3768 4000 s = "/%2F" + s.slice(2);
3769 4001 }
3770 4002 uriTokens.push(s);
@@ -3769,16 +4001,18 @@
3769 4001 }
3770 4002 uriTokens.push(s);
3771 4003 }
3772 4004 if (component.query !== void 0) {
3773 - uriTokens.push("?", component.query);
4005 + uriTokens.push("?", encodeQuery(component.query));
3774 4006 }
3775 4007 if (component.fragment !== void 0) {
3776 - uriTokens.push("#", component.fragment);
4008 + uriTokens.push("#", encodeFragment(component.fragment));
3777 4009 }
3778 4010 return uriTokens.join("");
3779 4011 }
3780 4012 var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
4013 + var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
4014 + var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
3781 4015 function getParseError(parsed, matches) {
3782 4016 if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3783 4017 return 'URI path must start with "/" when authority is present.';
3784 4018 }
@@ -3786,8 +4020,37 @@
3786 4020 return "URI port is malformed.";
3787 4021 }
3788 4022 return void 0;
3789 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 + }
3790 4053 function parseWithStatus(uri, opts) {
3791 4054 const options = Object.assign({}, opts);
3792 4055 const parsed = {
3793 4056 scheme: void 0,
@@ -3798,8 +4061,13 @@
3798 4061 query: void 0,
3799 4062 fragment: void 0
3800 4063 };
3801 4064 let malformedAuthorityOrPort = false;
4065 + let malformedPercentEncoding = false;
4066 + let malformedSchemeSpecific = false;
4067 + let malformedHost = false;
4068 + let malformedIPLiteral = false;
4069 + let malformedScheme = false;
3802 4070 let isIP = false;
3803 4071 if (options.reference === "suffix") {
3804 4072 if (options.scheme) {
3805 4073 uri = options.scheme + ":" + uri;
@@ -3806,8 +4074,27 @@
3806 4074 } else {
3807 4075 uri = "//" + uri;
3808 4076 }
3809 4077 }
4078 + const authorityMatch = uri.match(AUTHORITY_PREFIX);
4079 + if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
4080 + parsed.error = "URI authority must not contain a literal backslash.";
4081 + malformedAuthorityOrPort = true;
4082 + }
4083 + const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
4084 + if (introducerMatch !== null) {
4085 + const region = introducerMatch[1];
4086 + const normalizedRegion = region.replace(/[\t\n\r]/g, "");
4087 + if (normalizedRegion.length >= 2) {
4088 + if (normalizedRegion.slice(0, 2) !== "//") {
4089 + parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
4090 + malformedAuthorityOrPort = true;
4091 + } else if (region.length !== normalizedRegion.length) {
4092 + parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
4093 + malformedAuthorityOrPort = true;
4094 + }
4095 + }
4096 + }
3810 4097 const matches = uri.match(URI_PARSE);
3811 4098 if (matches) {
3812 4099 parsed.scheme = matches[1];
3813 4100 parsed.userinfo = matches[3];
@@ -3815,8 +4102,21 @@
3815 4102 parsed.port = parseInt(matches[5], 10);
3816 4103 parsed.path = matches[6] || "";
3817 4104 parsed.query = matches[7];
3818 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 + }
3819 4119 if (isNaN(parsed.port)) {
3820 4120 parsed.port = matches[5];
3821 4121 }
3822 4122 const parseError = getParseError(parsed, matches);
@@ -3826,11 +4126,18 @@
3826 4126 }
3827 4127 if (parsed.host) {
3828 4128 const ipv4result = isIPv4(parsed.host);
3829 4129 if (ipv4result === false) {
4130 + const bracketedIPLiteral = isIPLiteral(parsed.host);
4131 + const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3830 4132 const ipv6result = normalizeIPv6(parsed.host);
3831 - parsed.host = ipv6result.host.toLowerCase();
3832 - 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 + }
3833 4140 } else {
3834 4141 isIP = true;
3835 4142 }
3836 4143 }
@@ -3846,44 +4153,38 @@
3846 4153 if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
3847 4154 parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3848 4155 }
3849 4156 const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3850 - if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3851 - if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3852 - try {
3853 - parsed.host = new URL("http://" + parsed.host).hostname;
3854 - } catch (e) {
3855 - parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3856 - }
3857 - }
4157 + if (!malformedIPLiteral) {
4158 + malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3858 4159 }
3859 4160 if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3860 4161 if (uri.indexOf("%") !== -1) {
3861 - if (parsed.scheme !== void 0) {
3862 - 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);
3863 4165 }
3864 - if (parsed.host !== void 0) {
3865 - parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
3866 - }
3867 4166 }
3868 4167 if (parsed.path) {
3869 4168 parsed.path = normalizePathEncoding(parsed.path);
3870 4169 }
4170 + if (parsed.query) {
4171 + parsed.query = normalizeQueryFragmentEncoding(parsed.query);
4172 + }
3871 4173 if (parsed.fragment) {
3872 - try {
3873 - parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3874 - } catch {
3875 - parsed.error = parsed.error || "URI malformed";
3876 - }
4174 + parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3877 4175 }
3878 4176 }
3879 4177 if (schemeHandler && schemeHandler.parse) {
3880 4178 schemeHandler.parse(parsed, options);
4179 + if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4180 + malformedSchemeSpecific = true;
4181 + }
3881 4182 }
3882 4183 } else {
3883 4184 parsed.error = parsed.error || "URI can not be parsed.";
3884 4185 }
3885 - return { parsed, malformedAuthorityOrPort };
4186 + return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3886 4187 }
3887 4188 function parse(uri, opts) {
3888 4189 return parseWithStatus(uri, opts).parsed;
3889 4190 }
@@ -3890,22 +4191,30 @@
3890 4191 function normalizeString(uri, opts) {
3891 4192 return normalizeStringWithStatus(uri, opts).normalized;
3892 4193 }
3893 4194 function normalizeStringWithStatus(uri, opts) {
3894 - const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4195 + const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3895 4196 return {
3896 - normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3897 - malformedAuthorityOrPort
4197 + normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4198 + malformedAuthorityOrPort,
4199 + malformedPercentEncoding,
4200 + malformedSchemeSpecific,
4201 + malformedHost,
4202 + malformedScheme
3898 4203 };
3899 4204 }
3900 4205 function normalizeComparableURI(uri, opts) {
3901 - if (typeof uri === "string") {
3902 - const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3903 - return malformedAuthorityOrPort ? void 0 : normalized;
4206 + if (typeof uri !== "string" && typeof uri !== "object") {
4207 + return void 0;
3904 4208 }
3905 - if (typeof uri === "object") {
3906 - return serialize(uri, opts);
4209 + let value;
4210 + try {
4211 + value = typeof uri === "string" ? uri : serialize(uri, opts);
4212 + } catch {
4213 + return void 0;
3907 4214 }
4215 + const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4216 + return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3908 4217 }
3909 4218 var fastUri = {
3910 4219 SCHEMES,
3911 4220 normalize,
@@ -6564,11 +6873,11 @@
6564 6873 } });
6565 6874 }
6566 6875 });
6567 6876
6568 -// packages/abilities/node_modules/ajv-formats/dist/formats.js
6877 +// node_modules/ajv-formats/dist/formats.js
6569 6878 var require_formats = __commonJS({
6570 - "packages/abilities/node_modules/ajv-formats/dist/formats.js"(exports) {
6879 + "node_modules/ajv-formats/dist/formats.js"(exports) {
6571 6880 "use strict";
6572 6881 Object.defineProperty(exports, "__esModule", { value: true });
6573 6882 exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
6574 6883 function fmtDef(validate, compare) {
@@ -7145,11 +7454,11 @@
7145 7454 } });
7146 7455 }
7147 7456 });
7148 7457
7149 -// packages/abilities/node_modules/ajv-formats/dist/limit.js
7458 +// node_modules/ajv-formats/dist/limit.js
7150 7459 var require_limit = __commonJS({
7151 - "packages/abilities/node_modules/ajv-formats/dist/limit.js"(exports) {
7460 + "node_modules/ajv-formats/dist/limit.js"(exports) {
7152 7461 "use strict";
7153 7462 Object.defineProperty(exports, "__esModule", { value: true });
7154 7463 exports.formatLimitDefinition = void 0;
7155 7464 var ajv_1 = require_ajv();
@@ -7217,11 +7526,11 @@
7217 7526 exports.default = formatLimitPlugin;
7218 7527 }
7219 7528 });
7220 7529
7221 -// packages/abilities/node_modules/ajv-formats/dist/index.js
7530 +// node_modules/ajv-formats/dist/index.js
7222 7531 var require_dist2 = __commonJS({
7223 - "packages/abilities/node_modules/ajv-formats/dist/index.js"(exports, module) {
7532 + "node_modules/ajv-formats/dist/index.js"(exports, module) {
7224 7533 "use strict";
7225 7534 Object.defineProperty(exports, "__esModule", { value: true });
7226 7535 var formats_1 = require_formats();
7227 7536 var limit_1 = require_limit();