Skip to content

fetch for SVG source result in CSP violations. #1025

@billxinli

Description

@billxinli

It looks like the icons are loaded with fetch via data: schema

https://github.com/ionic-team/ionicons/blob/main/src/components/icon/request.ts#L13

With Content Security Policy headers enabled, the connect-src directive will block the icons from loading, unless if we also allow data: source.

However, this is not a safe practice. https://security.stackexchange.com/questions/94993/is-including-the-data-scheme-in-your-content-security-policy-safe

Refused to connect to 'data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Calendar</title><rect stroke-linejoin='round' x='48' y='80' width='416' height='384' rx='48' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='296' cy='232' r='24'/><circle cx='376' cy='232' r='24'/><circle cx='296' cy='312' r='24'/><circle cx='376' cy='312' r='24'/><circle cx='136' cy='312' r='24'/><circle cx='216' cy='312' r='24'/><circle cx='136' cy='392' r='24'/><circle cx='216' cy='392' r='24'/><circle cx='296' cy='392' r='24'/><path stroke-linejoin='round' stroke-linecap='round' d='M128 48v32M384 48v32' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linejoin='round' d='M464 160H48' class='ionicon-fill-none ionicon-stroke-width'/></svg>' because it violates the following Content Security Policy directive: "connect-src 'self' *.example.com".

I am curious, why is fetch used to load local resources?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA bug in the functionality of Ionicons

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions