Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Added support for Regex to determinate a data url#344

Open
sveneberth wants to merge 1 commit intomsaktype:masterfrom
viur-framework:viur
Open

Added support for Regex to determinate a data url#344
sveneberth wants to merge 1 commit intomsaktype:masterfrom
viur-framework:viur

Conversation

@sveneberth
Copy link

@sveneberth sveneberth commented Dec 6, 2019

There is currently a problem with SVGs in data-urls.

background-image: url('data:image/svg+xml;utf8,<svg ...> ... </svg>');

After formatting stylefmt return this:

background-image: url('data:image/svg+xml;utf8, <svg ...> ... </svg>');

A space is added after the comma, but this is an incorrect syntax (see RFC2397).

The reason for this incorrect syntax is that stylefmt expects data-urls encoded as base64, but this is still not required by the rfc.

Therefore I removed the base64 part in the regex to allow data ASCII data as well. The data: must be enough as indicator.

Of course we can match the base64 in the regex but this only a test and therefor I reduced it as far as possible.
Alternative would be:

/data:.+\/(.+)(;base64)?,(.*)/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant