Skip to content

fix: replace deprecated unescape() with modern UTF-8 encoding#7378

Merged
jasonsaayman merged 5 commits intoaxios:v1.xfrom
karan-lrn:fix/deprecate-unescape-and-jsdoc-typo
Apr 28, 2026
Merged

fix: replace deprecated unescape() with modern UTF-8 encoding#7378
jasonsaayman merged 5 commits intoaxios:v1.xfrom
karan-lrn:fix/deprecate-unescape-and-jsdoc-typo

Conversation

@karan-lrn
Copy link
Copy Markdown
Contributor

@karan-lrn karan-lrn commented Feb 8, 2026

  • Replace deprecated unescape(encodeURIComponent()) pattern with a regex-based encodeUTF8() helper function in resolveConfig.js
  • Fix incorrect JSDoc comment for isFileList in utils.js (said 'File' instead of 'FileList')

The new encodeUTF8 function produces identical output to the deprecated pattern, verified against existing basicAuth.spec.js test expectations.


Summary by cubic

Replaced deprecated unescape(encodeURIComponent()) with a modern UTF‑8 encoder for Basic Auth, and fixed the JSDoc for isFileList. No behavior change.

Description

  • Added encodeUTF8 helper in resolveConfig.js and used it for Basic Auth password before btoa().
  • Output matches the previous implementation; removes use of deprecated APIs.
  • Fixed JSDoc: isFileList returns true for FileList, not File.

Testing

  • No new tests; existing basicAuth.spec.js continues to pass.
  • Behavior is unchanged and covered by current tests.

Written for commit 91a4aa5. Summary will update on new commits. Review in cubic

- Replace deprecated unescape(encodeURIComponent()) pattern with a
  regex-based encodeUTF8() helper function in resolveConfig.js
- Fix incorrect JSDoc comment for isFileList in utils.js
  (said 'File' instead of 'FileList')

The new encodeUTF8 function produces identical output to the deprecated
pattern, verified against existing basicAuth.spec.js test expectations.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 4/5

  • Potential crash for non‑Latin1 usernames in lib/helpers/resolveConfig.js when creating the Authorization header via btoa, which could affect users with UTF‑8 credentials.
  • Overall risk is low since it’s a single moderate issue with limited scope, but it is user‑facing for non‑ASCII logins.
  • Pay close attention to lib/helpers/resolveConfig.js - ensure username is UTF‑8 encoded before btoa to avoid crashes.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="lib/helpers/resolveConfig.js">

<violation number="1" location="lib/helpers/resolveConfig.js:35">
P2: `btoa` throws on non‑Latin1 characters; since `auth.username` is passed through unchanged, non‑Latin1 usernames will crash during Authorization header creation. Encode the username to UTF‑8 bytes as well to avoid runtime failures.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/helpers/resolveConfig.js
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@jasonsaayman jasonsaayman self-requested a review as a code owner April 28, 2026 13:59
@jasonsaayman jasonsaayman merged commit 66337fc into axios:v1.x Apr 28, 2026
35 of 37 checks passed
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