Commit Graph

76 Commits

Author SHA1 Message Date
Jason Saayman
24c45391b6
fix: backport the fixes from the v1 branch 2026-04-10 21:17:29 +02:00
jasonsaayman
ee548ffbf6 fix: tests failing 2025-09-27 12:21:15 +02:00
Felix Bernhard
a1b1d3f073
fix: backport maxContentLength vulnerability fix to v0.x (#7034)
* backport `maxContentLength` check for `data:` protocol urls

* backport test for `estimateDataURLDecodedBytes`

* use CommonJS export

* use `var` instead of `const`

* replace `let` with `var`

* use standard function instead of arrow function
2025-09-16 16:21:06 +02:00
qiongshusheng
4840cb2bd0
fix: regular expression denial of service issues (#6708)
* fix: Regular Expression Denial of Service (ReDoS)

* fix test failed
2024-11-15 09:29:49 +02:00
Peter Williamson
3936f44b1a
Fix: omit nulls in params (#6394)
* fix: omit nulls when building params

* chore: fix prettier formatting

* fix: omit nulls when building params pt 2

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2024-05-24 18:41:46 +02:00
Sean Powell
146848f3e4
fix: backported commit #6167 and #6163 (#6402) 2024-05-24 18:38:36 +02:00
briwa
111811eadc
fix(backport): custom params serializer support (#6263) 2024-03-28 18:54:20 +02:00
Dmitriy Mozgovoy
c008e57fe4
Added axios.formToJSON method; (#4735)
* Draft

* Added `formDataToJSON` helper;
Added `axios.formToJSON` method;
Added client tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-25 08:21:40 +02:00
Dmitriy Mozgovoy
934f390cc3
URL params serializer; (#4734)
* Refactored BuildURL helper to use URLSearchParams serializer;

* Updated typings;
Added TS test;
2022-05-25 08:16:38 +02:00
Dmitriy Mozgovoy
467025bdb7
Fixed bug #4727 : toFormData Blob issue on node>v17; (#4728)
* Fixed bug #4727;
Added node 18.x to the CI;
Added hotfix for `ERR_OSSL_EVP_UNSUPPORTED` issue with karma running on node >=17.x;
Added `cross-env` to allow running build and test scripts on Windows platforms;

* Added conditional setting of `--openssl-legacy-provider` option for node versions >=17.x;

* Refactored ssl-hotfix & test script;

* Fixed and refactored default max body length test due to ECONNRESET failure;

* Added test for converting the data uri to a Blob;
Fixed bug with parsing mime type for Blob;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-20 16:31:26 +02:00
Dmitriy Mozgovoy
c30252f685
Added data URL support for node.js; (#4725)
* Added data URL support for node.js;
Added missed data URL protocol for the browser environment;
Optimized JSON parsing in the default response transformer;
Refactored project structure;
Added `cause` prop for AxiosError instance that refers to the original error if it was wrapped with `AxiosError.from` method;
Added fromDataURI helper;
Added test for handling data:url as an `arraybuffer|text|stream`;

* Added throwing of 405 HTTP error if the method is not GET;
2022-05-20 08:04:36 +02:00
Dmitriy Mozgovoy
bd391247b4
Added the ability for the url-encoded-form serializer to respect the formSerializer config; (#4721)
Added test for `formSerializer` config in context of `url-encoded-form` serializer;
2022-05-17 08:26:35 +02:00
Dmitriy Mozgovoy
c05ad48952
Fixed toFormData regression bug (unreleased) with Array-like objects serialization; (#4714)
Added `toURLEncodedForm` helper;
Added automatic payload serialization to `application/x-www-form-urlencoded` to have parity with `multipart/form-data`;
Added test of handling `application/x-www-form-urlencoded` body by express.js;
Updated README.md;
Added missed param in JSDoc;
Fixed hrefs in README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:30:17 +02:00
Dmitriy Mozgovoy
807918bda2
Added enhanced toFormData implementation with additional options support; (#4704)
Updated default notation for arrays and objects to bracket style;
Added `multer/express.js` tests;
Updated README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-11 19:30:08 +02:00
暴走老七
4c898f8665
don\'t need to transform arguments to array (#4544)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:08:57 +02:00
JALAL
eef2f97281
replace deprecated substr() with slice() (#4468)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:39:40 +02:00
Jingyi Lin
ba85e0e385
style: fix word spelling ang lint style in comment (#4500)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:12:16 +02:00
Dmitriy Mozgovoy
b9e9fb4fa0
Enhanced protocol parsing implementation to fix #4633; (#4639)
Added unit tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-04-27 11:30:50 +02:00
Jay
3e0954db22 Fixed merge conflicts 2022-04-01 20:41:47 +02:00
Jay
8699891b8e Fixed merge conflicts 2022-04-01 18:40:12 +02:00
Dmitriy Mozgovoy
6b9b05b907
Improved FormData support; (#4448)
* Fixed isFormData predicate;
Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;

* Added the `form-data` package as a dependency for the server build;
Added tests for FormData payload;

* Added FormData automatic serialization section;
Refactored cancellation section;

* Reworked toFormData helper;
Expose toFormData helper as a static method;
Refactored transform request;
Added kindOf, kindOfTest, endsWith, isTypedArray util;
Refactored utils.js to use kindOf for tests;

* Fixed isFormData predicate; (#4413)

Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment using `form-data` package;

(cherry picked from commit 73e3bdb883)

* Added shortcut methods `postForm`, `putForm`, `patchForm` to submit a Form;
Added ability to submit FileList object as a FormData;
Updated README.md;

* Updated README.md;
2022-03-14 20:22:10 +02:00
Jay
d8d43c1ffd Mended merge conflicts 2022-03-09 19:41:56 +02:00
Jay
d660e29c1a
Revert "Fixed isFormData predicate; (#4413)" (#4472)
This reverts commit 73e3bdb883.
2022-02-13 15:47:38 +02:00
carpben
e3002e1fda Separate responsibility between transformRequest and toFormData 2022-02-13 09:02:22 +02:00
Dmitriy Mozgovoy
73e3bdb883
Fixed isFormData predicate; (#4413)
Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;
2022-02-02 13:48:44 +02:00
狼族小狈
a8cd75a081
Update isAbsoluteURL.js (#3809)
Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect, as demonstrated in the following example:

https://eslint.org/docs/rules/no-useless-escape

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 13:33:16 +02:00
Ben Carp
99648153ce
toFormData helper function (#3757)
* adding toFormData test

* adding toFormData

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:21:51 +02:00
Black-Hole
6fca6a7027
refactor(helpers): optimize the logic of isAxiosError (#3546)
1. add the judgment of null

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:09:33 +02:00
DigitalBrainJS
7f1236652a Refactored AxiosError to a constructor;
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
2021-10-14 19:15:16 +03:00
Jay
76f09afc03
Release/v0.22.0 (#4107)
* fix/Avoid package.json import; (#4041)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Feat/export package version constant (#4065)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Export package version constant;

* Fixed cancelToken leakage; Added AbortController support; (#3305)

* Fixed cancelToken leakage;
Added AbortController support;

* Fixed typings;

* Documented `signal` option;

* Added processing of early cancellation using AbortController without sending a request;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Updating CI to run on release branches

* Fixed default transitional config for custom Axios instance; (#4052)

Refactored `/core/mergeConfig`;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Prepping v0.22.0 for release

* Updated date

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
2021-10-01 08:02:13 +02:00
Dmitriy Mozgovoy
5ad6994da3
JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* Draft

* Added support for primitive types to be converted to JSON if the request Content-Type is 'application/json';
Added throwing SyntaxError if JSON parsing failed and responseType is json;
Added transitional option object;
Added options validator to assert transitional options;
Added transitional option `silentJSONParsing= true` for backward compatibility;
Updated README.md;
Updated typings;

* Fixed isOlderVersion helper;
Fixed typo;
Added validator.spec.js;

* Added forcedJSONParsing transitional option #2791

* `transformData` is now called in the default configuration context if the function context is not specified (for tests compatibility);

* Added `transitional.clarifyTimeoutError` to throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts;
Added support of onloadend handler if available instead of onreadystatechange;
Added xhr timeout test;
Fixed potential bug of xhr adapter with proper handling timeouts&errors (FakeXMLHTTPRequest failed to handle timeouts);
2021-04-19 18:55:34 +02:00
Jason Kwok
f472e5da5f
Adding a type guard for AxiosError (#2949)
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
2020-11-03 10:01:07 +02:00
David
8a8c534a60
Fixing special char encoding (#1671)
* removing @ character from replacement list since it is a reserved character

* Updating buildURL test to not include the @ character

* Removing console logs

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-27 14:37:39 +02:00
Xianming Zhong
c7488c7dd5 Remove unnecessary XSS check introduced by #2451 (#2679)
* Remove unnecessary XSS check introduced by #2451

* Remove test file of `isValidXss`
2020-01-20 09:20:33 -07:00
Yasu Flores
841466416b
Fix XSS logic that matched some valid urls (#2529)
* Fix XSS logic that matched some valid urls, e.g. "/one/?foo=bar", when it shouldn't match those
2019-11-07 18:39:24 -08:00
Felipe Martins
097948698a
Revert "Update Webpack + deps, remove now unnecessary polyfills" (#2479)
* Revert "Update Webpack + deps, remove now unnecessary polyfills (#2410)"

This reverts commit 189b34c45a.

* Fix build (#2496)

* Change syntax to see if build passes

* Test commit

* Test with node 10

* Test adding all browsers in travis

* remove other browsers when running on travis
2019-10-25 11:34:47 -03:00
Avindra Goolcharan
189b34c45a Update Webpack + deps, remove now unnecessary polyfills (#2410)
* Update deps

 * handles webpack 1 -> 4 migration

* remove promise helpers from dev files

assume `Promise` is available, or polyfilled by
the consumer

* Remove isArray util. `isArray` has good coverage, even
   in IE9. So lets remove the custom polyfill.

 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

also resolves a few lint issues

* Remove trim util

String.protoype.trim has good coverage (including IE9)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

Also, the http adapter already uses the native method.
2019-10-21 15:56:29 -03:00
Yasu Flores
29da6b24db Fix to prevent XSS, throw an error when the URL contains a JS script (#2464)
* Fixes issue where XSS scripts attacks were possible via the URL

* Fix error

* Move throwing error up

* Add specs and make regex cover more xss cases
2019-10-16 07:53:10 -03:00
Wataru
19969b4fbd Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… (#2451)
* Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scripting

* use var insted of const
2019-10-08 21:23:34 -03:00
Anatoly Ryabov
81eaa3db4c Fixing building url with hash mark (#1771)
This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#`
2018-09-04 09:53:57 +02:00
Rikki Gibson
e9c481fa5e Delete btoa polyfill 2018-08-06 09:56:51 +02:00
Justin Beckwith
22c2baf205 chore: upgrade eslint and add fix command 2018-04-06 21:50:26 -07:00
刘涛
a1e895d670
Update buildURL.js
Two if statements is unnecessary, we can replace with "if ... else ..."
2017-11-23 16:22:55 +08:00
Tyler Brown
fb08e95603 Duplicate header handling (#874)
* Update parseHeaders to match node http behavior

Node ignores duplicate entries for certain HTTP headers.

It also always converts the `set-cookie` header into an array.

* add tests for new duplicate header handling

* clarify comment
2017-08-12 14:58:10 +02:00
Lochlan Bunn
fe7d09bb08 Fixing combineURLs to support an empty relativeURL (#581)
* Fixing combineURLs to support an empty relativeURL

When combining the base and relative URLs, we should forego force
appending a slash to the base when the relative URL is empty.
This leads to a semantic url.

* Fixing combineURLs, allowing single slash relatives
2016-12-07 21:23:45 -08:00
Matt Zabriskie
203cbc2da0 Moving settle & transformData from helpers/ -> core/ 2016-06-01 13:54:38 -06:00
Matt Zabriskie
eea790b8de Adding README to modules 2016-06-01 13:16:16 -06:00
Nick Uraltsev
f20490eb6b Adding support for URLSearchParams 2016-05-07 12:26:28 -07:00
Nick Uraltsev
fa9444e0ba Allow custom HTTP status code error ranges (#308)
Adding support for custom HTTP status code error ranges
2016-04-26 14:18:58 -06:00
Matt Zabriskie
7041775943 Changing btoa ponyfill to improve testing 2016-03-03 22:43:16 -07:00