You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without ";base64", the data (as a sequence of octets) is represented using ASCII encoding for octets inside the range of safe URL characters and using the standard %xx hex encoding of URLs for octets outside that range.
Unfortunately, they do not define what safe URL characters are. However, there is a formal definition of the syntax of a data URL in Chapter 3:
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype := [ type "/" subtype ] *( ";" parameter )
data := *urlchar
parameter := attribute "=" value
urlchar is a reference to RFC2396 which is superseded by RFC3986.
The deprecated RFC2396 does not define a urlchar but a uric, which I believe is what is meant.
In the newer RFC3986, appendix D.2 provides a convenient translation of the now obsolete uric:
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
I'm not 100% sure if it's a bug in the validator or in Vite, but after digging through RFCs for way too long, I think it's a bug in Vite.
It's not a valid data URI in RFC 2397, but the browsers that follows the Fetch Standard (all evergreen browsers) are possible to parse it correctly. The Fetch Standard defines a decode steps that can parse data URI that contains non-uric.
It's a bit bad behavior, but it reduces the file size significantly and these kinds of non spec-compliant data URIs are ubiquitous as mini-svg-data-uri package that generates them was recommended by url-loader.
Describe the bug
When inlining SVGs, Vite does not escape special characters such as curly brackets.
example.svg
:entry-server.js
:Output:
This is flagged by https://validator.w3.org/ as an error:
I'm not 100% sure if it's a bug in the validator or in Vite, but after digging through RFCs for way too long, I think it's a bug in Vite.
Why I think this is a Vite bug
RFC 2397 states
Unfortunately, they do not define what safe URL characters are. However, there is a formal definition of the syntax of a data URL in Chapter 3:
urlchar
is a reference to RFC2396 which is superseded by RFC3986.The deprecated
RFC2396
does not define aurlchar
but auric
, which I believe is what is meant.In the newer
RFC3986
, appendix D.2 provides a convenient translation of the now obsoleteuric
:The relevant
unreserved
andpct-encoded
are defined in Section 2.3. and Section 2.1.:This also seems to be consistent with which characters JavaScript's
encodeURI
function encodes.Reproduction
https://stackblitz.com/edit/vite-ssr-28jd81?file=src%2Fexample.svg
Steps to reproduce
No response
System Info
System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vite: ^5.4.9 => 5.4.11
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: