Skip to content

Add support for custom stylesheet URL in UserCSS extension #7107

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

Open
wants to merge 7 commits into
base: edge
Choose a base branch
from

Conversation

Rambomst
Copy link

@Rambomst Rambomst commented Dec 15, 2024

Changes proposed in this pull request:

  • This update introduces the ability for users to specify a custom stylesheet URL in the UserCSS extension.
  • It includes configuration fields, backend handling, and CSP updates to allow external stylesheets while maintaining security. Existing functionality remains untouched.

How to test the feature manually:

  1. Go to the User CSS settings area.
  2. Set a custom stylesheet URL.
  3. Load the FreshRSS main page and view the page source to see the custom stylesheet URL has been loaded.

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

This update introduces the ability for users to specify a custom stylesheet URL in the UserCSS extension. It includes configuration fields, backend handling, and CSP updates to allow external stylesheets while maintaining security. Existing functionality remains untouched.
@Frenzie Frenzie changed the title Add support for custom stylesheet URLs in UserCSS extension Add support for custom stylesheet URL in UserCSS extension Dec 16, 2024
Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

lgtm

@Frenzie Frenzie added this to the 1.25.0 milestone Dec 16, 2024
@math-GH
Copy link
Contributor

math-GH commented Dec 16, 2024

what is the use case?

link: FreshRSS/Extensions#261

Adjusted method bracket placement to align with coding standards. These changes improve code readability and maintain consistency across the codebase. No functional behavior was altered.
@Rambomst Rambomst force-pushed the add-custom-stylesheet-url-setting branch from 941f241 to 65befc0 Compare December 17, 2024 00:13
@Alkarex Alkarex modified the milestones: 1.25.0, 1.26.0 Dec 17, 2024
@Alkarex
Copy link
Member

Alkarex commented Dec 17, 2024

I am a bit worried of having something like that in the core, which dynamically modifies CSP security headers.
What would be a typical location for your CSS file, in your personal use case, @Rambomst ?

@Rambomst
Copy link
Author

I am a bit worried of having something like that in the core, which dynamically modifies CSP security headers. What would be a typical location for your CSS file, in your personal use case, @Rambomst ?

I have the CSS file sitting in another docker container on the same server though its referenced using a full domain https://example.com/my.css.

Since this is a user based plugin and the CSS URL entered will only be displayed to the current logged in user after they themselves have set the URL, would it be a huge concern? Perhaps a warning message about the potential perils of not using a domain under your control?

@Alkarex
Copy link
Member

Alkarex commented Dec 17, 2024

We should in particular double-check that this is not used for instance on the login screen, if used by the default user

Introduced hasValidStylesheetUrl method to encapsulate URL validation, enhancing readability and maintainability. This change also addresses static analysis issues.
@Rambomst Rambomst force-pushed the add-custom-stylesheet-url-setting branch from 8aab4c2 to 8df544b Compare December 30, 2024 23:56
@math-GH
Copy link
Contributor

math-GH commented Jan 8, 2025

My 2 cents here:
I am not a fan of having this security change inside a default delivered extension.
I understand the use case but to honest: If you have hundrets/thousands of CSS lines added why do not develop a new own theme? It is very simple to use the CSS files from exisiting themes and create new CSS files.

But open a potential stream into the web just for a very very very very rare use case makes me a bad gut feeling

@Rambomst
Copy link
Author

Rambomst commented Jan 8, 2025

@math-GH

but to honest: If you have hundrets/thousands of CSS lines added why do not develop a new own theme?

The stylesheet I am using is actually shared by a few applications so that's why I needed something like this over a custom theme.

But open a potential stream into the web just for a very very very very rare use case makes me a bad gut feeling

The only time anything is changed is if a user sets a URL otherwise the CSP values remain unchanged, but I also get where you are coming from. Originally I just had this as a custom extension but when I opened a PR to add my extension to the list of third party extensions available I was told to do this instead and that PR there hasn't been merged.

@Frenzie
Copy link
Member

Frenzie commented Jan 9, 2025

It is very simple to use the CSS files from exisiting themes and create new CSS files.

That's talking from the perspective of a server administrator. From the perspective of a user that isn't very simple but completely impossible.

But open a potential stream into the web just for a very very very very rare use case makes me a bad gut feeling

Imho the complete opposite of rare among the audience most likely to use FreshRSS.

Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

I'd like to take this opportunity to vehemently object to making things worse for the purposes of "security".

@Frenzie
Copy link
Member

Frenzie commented Jan 9, 2025

@Rambomst

The only time anything is changed is if a user sets a URL otherwise the CSP values remain unchanged, but I also get where you are coming from. Originally I just had this as a custom extension but when I opened a PR to add my extension to the list of third party extensions available I was told to do this instead and that PR there hasn't been merged.

Imo it should either be part of CustomCSS or part of the server config and it doesn't make sense as a separate extension, but my expectation would be that if you disagreed you would've said so rather than jumping straight into implementing it in CustomCSS. ;-)

Ensure URL is not null before validation and simplify the `hasValidStylesheetUrl` method. This improves code clarity and prevents potential null value issues.
@Alkarex Alkarex modified the milestones: 1.26.0, 1.27.0 Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy