Skip to content

fix(utils): Add null check to parseCrossOriginStylesheet, closes #5074#5075

Open
dcbroad3 wants to merge 3 commits intodequelabs:developfrom
dcbroad3:develop
Open

fix(utils): Add null check to parseCrossOriginStylesheet, closes #5074#5075
dcbroad3 wants to merge 3 commits intodequelabs:developfrom
dcbroad3:develop

Conversation

@dcbroad3
Copy link
Copy Markdown

If a null href is passed to parseCrossOriginStylesheet, the function will currently convert that to the string "null" and attempt to load that href. This PR adds a null check so that the function instead returns early if a nullish href is passed, similar to how parseSameOriginStylesheet returns early if a sheet includes no rules.

Closes:
#5074

@dcbroad3 dcbroad3 requested a review from a team as a code owner April 14, 2026 17:29
Copilot AI review requested due to automatic review settings April 14, 2026 17:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses axe-core issue #5074 by preventing parseCrossOriginStylesheet from attempting to fetch a stylesheet when the provided href/URL is nullish, avoiding erroneous network requests like "null".

Changes:

  • Add a nullish check in parseCrossOriginStylesheet to return early when url == null.
  • Add a unit test intended to cover the nullish-URL case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/core/utils/parse-crossorigin-stylesheet.js Adds early return when the cross-origin stylesheet URL is nullish.
test/core/utils/parse-crossorigin-stylesheet.js Adds coverage for the nullish-URL behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

isCrossOrigin
) {
if (url == null) {
return Promise.resolve();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am following the pattern of the early return in parseSameOriginStylesheet if rules is falsy, but let me know if a different result should be returned (or if the function should do an early reject instead?)

Comment thread test/core/utils/parse-crossorigin-stylesheet.js Outdated
Comment thread test/core/utils/parse-crossorigin-stylesheet.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants