Skip to content

CSP errors caused by Drawer #18910

@FunkeyFlo

Description

@FunkeyFlo

Describe the bug

Drawer component causes CSP violations with a strict CSP policy on style-src-attr.

This is caused due to the component using the setAttribute function from primeuix to set styling.

This is done at the lines:

Example of valid/invalid usage

// invalid usage: which causes csp violation
document.querySelector("div").setAttribute("style", "display:none;");

// proper usage
document.querySelector("div").style.cssText = "display:none;";

There don't seem to be any other usages in the project that use setAttribute to influence styling.

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

I'm not sure if you prefer to change the inner working of primeuix setAttribute to detect styling usage or wether you just want to change these two invocations.

Reproducer

https://stackblitz.com/edit/github-l9aakal4?file=src%2Findex.html

Environment

Image

Angular version

20

PrimeNG version

v20

Node version

24.4.1

Browser(s)

Edge 140

Steps to reproduce the behavior

  1. Add style-src-attr 'self' to CSP policy. (meta tag or header)
  2. Open a drawer component in your browser
  3. Check (browser) console for CSP errors.

Expected behavior

Component shouldn't cause CSP errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleIssue or pull request is inactivity and unfortunately it will be *closed* if there is no responseStatus: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions