Repository navigation
refactor: Bump fast-uri from 3.1.8 to 3.1.9 - #3511
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
🎉 This change has been released in version 9.3.0-alpha.15 |
|
🎉 This change has been released in version 10.0.0 |
Closes #3504
Replaces the Dependabot PR with a lock file regenerated on the current
alpha. Only thefast-urientry changes. Dependabot's lock also removed the optional peer entriesgcp-metadata7.0.1 and its nestedgaxios7.3.1; this PR keeps them.fast-uriis a transitive development dependency:webpack→schema-utils4.3.3 →ajv8.18.0 (also viaajv-formats2.1.1 →ajv8.18.0). It is not in the production dependency tree (npm ls fast-uri --omit=devis empty).Changes
%6Aavascript:, is no longer decoded into a livejavascript:scheme.parse()now reportsURI scheme is malformed., andserialize()andresolve()throw.http,https,wsandwss, a host containing an ASCII control character, space, DEL, a backtick or any of"#/:<>?@[\]^{|}is now rejected withURI host is malformed.(aparse()error;resolve()throws). The same applies to a host that the WHATWG URL parser does not read entirely as a host. Before, such hosts were silently rewritten:http://a@b@evil.example/became hostevil.example, and TAB, CR and LF were stripped...segments and never makes the path root-relative. For example,a/../bis nowbinstead of/b, and../xstays../xinstead ofx. A result that would be empty, start with//, or have a colon in its first segment is prefixed with./.resolve()applies the same rule when the base URI has neither scheme nor authority.reference: 'suffix', a colon in the first path segment of a reference without authority is now escaped, so the output cannot be reparsed as a scheme.serialize()now re-applies path encoding (serializePathEncoding) to a reference without scheme and authority even whenskipEscapeis set, which is the moderesolve()uses to serialize its result. 3.1.8 skipped this step underskipEscape. The step percent-encodes every character outside the RFC 3986 path character set, and a colon in the first path segment.This fixes the Dependabot alerts for all four advisories above.
Impact on this project
ajv8.18.0 calls onlyparse(),serialize()andresolve()offast-uri, to resolve schema$idand$refvalues. It never callsnormalize()orequal(), and never usesreference: 'suffix'.schema-utils,ajv-formatsandajv-keywordsdo not usefast-uridirectly.Both versions were compared empirically through the real
schema-utils4.3.3 →ajv8.18.0 call path.ajvcompiles and validates differently only under these conditions:$idor a relative one, and the relative path of a$refor nested$idhas dot segments that reach the start of the merged path. That means leading..segments that cannot be collapsed,..segments that remove the first segment (a/../b), a path that reduces to nothing (.), or a colon in the first segment after./(./a:b). The ref now resolves per RFC 3986 instead of being made root-relative, losing its leading..segments, or exposing the colon as a scheme. Dot segments elsewhere resolve as before. For example, with$id: "dir/root.json",$ref: "../other.json"resolved to/other.json(MissingRefError) and now resolves toother.json. With$id: "root.json",$ref: "a/../b"resolved to/band now resolves tob.$idor$ref: for example,$id: "%6Aavascript:alert(1)"compiled before (decoded tojavascript:). Compilation now throwsURI scheme is malformed.http,https,wsorwsshost in a$idor$ref: compilation throwsURI host is malformed.whenajvresolves a$refagainst, or to, a URI whose host matches the rejected forms above. For example,$id: "http://a@b@evil.example/s.json"with a$refcompiled before, with the host rewritten toevil.example.No development-tooling schema uses the percent-encoded-scheme or malformed-host forms, and none of the 44 schema files checked has an
$id. The files checked are those ofwebpack5.106.2,terser-webpack-plugin5.4.0,css-loader7.1.5,style-loader3.3.1,sass-loader16.0.7 andbabel-loader10.1.1.Dot-segment refs without an
$idappear in 11webpackplugin schema files (../../WebpackOptions.json#/definitions/...and./ModuleFederationPlugin.json#/...). Their target is never registered withajv, so they fail with the sameMissingRefErrormessage in both versions; only the error's internalmissingRefvalue changes.webpackcompiles only two of them (JsonModulesPluginParser.jsonandJsonModulesPluginGenerator.json), and only when its precompiled check rejectsmodule.parser.jsonormodule.generator.jsonoptions. This project does not set those options.The re-applied path encoding in
resolve()has no observable effect here.parse()already percent-encodes characters outside the path character set (normalizePathEncoding), andresolve()parses both of its inputs that way, so the step finds nothing left to encode.resolve()returned identical results in both versions for every such character tested: space,",<,>,\,^, backtick,{,},|,[,], a control character, non-ASCII characters and emoji, and malformed%. The bases tested were"",dir/schema.jsonandhttps://example.com/a/b.json. In the reachable schemas, the only$refvalues with a path are../../WebpackOptions.jsonand./ModuleFederationPlugin.json, which contain only unreserved characters,.and/. All other$refvalues are fragment-only (#/definitions/...), and no schema has an$id.Validation results, including the full error messages, are identical between 3.1.8 and 3.1.9 for:
css-loader,style-loader,sass-loaderandbabel-loaderoption schemas, with this project's loader options and with invalid optionsterser-webpack-pluginoptions schema, withwebpack's production defaults and with invalid optionswebpack'sWebpackOptions.json, with a configuration like this project's and with an invalid onewebpack's in-memory asset, CSS and JSON parser and generator schemasBreaking Changes
None
Code Changes Required
None — the upgrade is a drop-in replacement.
Summary by CodeRabbit