Skip to content

#6233 Improve css validation#6234

Draft
martgil wants to merge 1 commit into
masterfrom
issue-6233-improve-css-validation
Draft

#6233 Improve css validation#6234
martgil wants to merge 1 commit into
masterfrom
issue-6233-improve-css-validation

Conversation

@martgil
Copy link
Copy Markdown
Collaborator

@martgil martgil commented May 29, 2026

This PR improves currently implemented css validation on rendered elements in pgp_block.

Closes #6233


Tests (delete all except exactly one):

  • Does not need tests (refactor only, docs or internal changes)

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

@martgil martgil requested a review from sosnovsky as a code owner May 29, 2026 08:15
@martgil
Copy link
Copy Markdown
Collaborator Author

martgil commented May 29, 2026

Hi @sosnovsky - This one is ready for a review. Thank you!

const style = node.getAttribute('style')?.toLowerCase();
if (style && (style.includes('url(') || style.includes('@import'))) {
node.removeAttribute('style'); // don't want any leaks through css url()
return; // stop processing: do not re-add any part of this style attribute
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if return will be executed here, then all next checks will be skipped?

so if style property includes some URL, then other checks for node.tagName === 'IMG' and node.tagName === 'A' won't be executed?
for example, <img src="https://example.com/tracker.png" style="background-image: url(https://example.com/bg.png)"> will return <img src="https://example.com/tracker.png"> - style property removed, but remote image is loaded

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I realize I should formulate even better logic to fix this rather than what's current. BRB.

@martgil martgil marked this pull request as draft May 29, 2026 10:30
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.

Improve CSS validation

2 participants