Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode inline SVGs #614

Merged
merged 2 commits into from
Jul 18, 2024
Merged

Encode inline SVGs #614

merged 2 commits into from
Jul 18, 2024

Conversation

kasperg
Copy link
Contributor

@kasperg kasperg commented Apr 29, 2024

Description

When using an inline SVG it must be encoded. Otherwise browsers may choke on it due to unescaped characters like < and ".

At the moment problem can be seen when the Chromatic/Cypress integration tries to generate pages with inline CSS. Without this process fails and CSS is never loaded.

To address this we encode the inline CSS using
https://yoksel.github.io/url-encoder/. A proper SCSS function to address this would be preferable but I could not find such a thing.

We only have a few actual instances of inline SVGs to for now it should be OK to just change these.

This is needed for danskernesdigitalebibliotek/dpl-cms#1333

Base automatically changed from release/hermod-13 to develop April 30, 2024 14:06
@kasperg kasperg changed the base branch from develop to release/hermod-14 April 30, 2024 14:08
Base automatically changed from release/hermod-14 to develop May 2, 2024 14:12
@kasperg kasperg force-pushed the encode-inline-svgs branch 4 times, most recently from 95d99f2 to 28d5d51 Compare July 2, 2024 11:56
When using an inline SVG it must be encoded. Otherwise browsers may
choke on it due to unescaped characters like < and ".

At the moment problem can be seen when the Chromatic/Cypress
integration tries to generate pages with inline CSS. Without this
process fails and CSS is never loaded.

To address this we encode the inline CSS using
https://yoksel.github.io/url-encoder/. A proper SCSS function to
address this would be preferable but I could not find such a thing.

We only have two actual instances of inline SVGs to for now it should
be OK to just change these.

The fact that this is a nice change is also indicated by the fact that
we no longer have stylelint issues that has to be ignored.
@kasperg kasperg force-pushed the encode-inline-svgs branch from 28d5d51 to 2f8cb76 Compare July 3, 2024 06:57
@kasperg kasperg marked this pull request as ready for review July 5, 2024 06:24
@kasperg kasperg marked this pull request as draft July 5, 2024 06:27
@kasperg
Copy link
Contributor Author

kasperg commented Jul 5, 2024

The Chromatic tests currently fail for an SVG. We need to fix this before this can be merged.

@kasperg kasperg assigned kasperg and unassigned rasben, LasseStaus and kasperbirch1 Jul 16, 2024
The style element makes Chrome not render the background image. Also
it is not really needed as a separate style element.

Convert it to attributes on the element instead.
@kasperg kasperg marked this pull request as ready for review July 16, 2024 12:18
@kasperg
Copy link
Contributor Author

kasperg commented Jul 16, 2024

The Chromatic tests currently fail for an SVG. We need to fix this before this can be merged.

This has now been fixed.

@kasperg kasperg removed their assignment Jul 17, 2024
@rasben rasben assigned kasperg and unassigned rasben Jul 18, 2024
@kasperg kasperg merged commit cb1b89d into develop Jul 18, 2024
9 checks passed
@kasperg kasperg deleted the encode-inline-svgs branch July 18, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants