2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/unit
Abhishek Chauhan 5061879649 fix: update fromDataURI regex to match RFC 2397 (#10829)
* fix: update fromDataURI regex to match RFC 2397

Update the DATA_URL_PATTERN regex to correctly match all valid RFC 2397
data URIs. The previous regex required a semicolon-terminated media type
segment, which rejected valid data URIs like `data:;base64,MTIz` and
`data:application/octet-stream,123`.

Fixes #10808

* fix: normalize omitted mediatype to text/plain per RFC 2397

When a data URI has parameters but no mediatype (e.g. data:;charset=UTF-8,...),
prepend text/plain as the default per RFC 2397 section 3.

* fix: use stricter RFC 2397 regex and expand test matrix

- Switch to type/subtype-aware regex from #10808
- Require name=value parameters, separate ;base64 group
- Add tests: charset param, URL-encoded body, Blob type
  preservation, datax: rejection, missing comma rejection
- Normalize omitted mediatype to text/plain per RFC 2397 §3

* chore: apply small nits

---------

Co-authored-by: Abhishek Chauhan <abhishek-chauhan@outlook.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2026-05-05 19:23:16 +02:00
..