Commit 208a708
authored
fix(svg): escape ampersands in Google Fonts import URLs (JhaSourav07#1706)
## Description
Fixes JhaSourav07#1705
This PR fixes an XML/SVG syntax issue in the auto-theme SVG generators.
When a custom Google Font is requested, `generateAutoThemeSVG` and
`generateAutoThemeMonthlySVG` generate a Google Fonts `@import` URL
containing a raw `&display=swap` parameter inside an SVG `<style>`
block.
Because SVG is XML-based and the stylesheet is not wrapped in CDATA, raw
ampersands are invalid XML and can cause parsing or rendering failures
in strict SVG/XML parsers.
### Changes
* Replaced raw `&display=swap` with `&display=swap`
* Updated:
* `generateAutoThemeSVG`
* `generateAutoThemeMonthlySVG`
* Aligned implementation with other SVG generators in the codebase that
already use XML-safe escaped URLs
### Before
```css
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
```
### After
```css
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
```
This preserves existing functionality while ensuring generated SVG
output remains valid XML.
## Pillar
* [ ] 🎨 Pillar 1 — New Theme Design
* [ ] 📐 Pillar 2 — Geometric SVG Improvement
* [ ] 🕐 Pillar 3 — Timezone Logic Optimization
* [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
N/A (No visual changes)
This change only affects XML escaping within generated SVG `<style>`
blocks and does not alter the rendered output.
## Checklist before requesting a review:
* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
* [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
* [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
* [ ] I have updated `README.md` if I added a new theme or URL
parameter.
* [x] I have started the repo.
* [x] I have made sure that i have only one commit to merge in this PR.
* [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
* [ ] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.3 files changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1208 | 1208 | | |
1209 | 1209 | | |
1210 | 1210 | | |
1211 | | - | |
| 1211 | + | |
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | | - | |
| 509 | + | |
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| |||
966 | 966 | | |
967 | 967 | | |
968 | 968 | | |
969 | | - | |
| 969 | + | |
970 | 970 | | |
971 | 971 | | |
972 | 972 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| |||
1033 | 1033 | | |
1034 | 1034 | | |
1035 | 1035 | | |
1036 | | - | |
| 1036 | + | |
1037 | 1037 | | |
1038 | 1038 | | |
1039 | 1039 | | |
| |||
0 commit comments