fix: parse data uris according to rfc 2397#7295
Conversation
5b8e04c to
0aac668
Compare
0aac668 to
a37e799
Compare
This comment was marked as spam.
This comment was marked as spam.
1 similar comment
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for this, and apologies for the slow review. The bug is real. I traced each of the three failing cases against the current regex and they all genuinely throw Where I'd like to land differently is the dependency. I've opened #10808 to track the maintainer-led version with a compliant pattern and your test cases ported over to the vitest suite. Closing this one in favour of that. Genuinely appreciate the failing cases and the test work, both of which made the issue easy to write up. |
This PR replaces the non-compliant
DATA_URL_PATTERNregular expression infromDataURIwith thedata-uri-to-bufferlibrary, which is compliant with RFC 2397.Before this change, the following valid Data URIs resulted in
Invalid URL:data:;base64,MTIzdata:application/octet-stream,123data:text/plain;charset=US-ASCII,123It uses
data-uri-to-buffer@3, which supports Node.js 6+.