Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

mindspank
Copy link
Contributor

@mindspank mindspank commented Oct 3, 2025

Closes APP-429

Implements the backend parser for css based themes

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@mindspank mindspank marked this pull request as ready for review October 8, 2025 09:09
return nil, fmt.Errorf("cannot use both legacy color properties (primary, secondary) and the new CSS property simultaneously")
}

if hasLegacyColors {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the old color codes are now legacy, would it make sense to rewrite them to CSS and save them in the css property of the theme resource instead? I.e. so we can remove the colors fields from the theme resource and only have the css field.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mindspank does it make anything easier in UI if we deprecate old format all together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not majorly, I would rather keep the old for now and we can refactor that out later

Comment on lines 115 to 116
// Allowed URL schemes
var allowedSchemes = regexp.MustCompile(`^(https?|data:image|#)`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does our CSP policies need to be updated to support arbitrary references? (And can we do it safely?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good question. Will need to test it on non-localhost to make sure.

// Allowed URL schemes
var allowedSchemes = regexp.MustCompile(`^(https?|data:image|#)`)

func sanitizeCSS(c string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question – how safe do you feel this is? Quick effort or thorough? And how serious are the attack opportunities?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This was quick effort. We definitely need a deeper look at this before we release this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also sanitize on the frontend as opposed to the backend, library support should be a bit wider there

Copy link
Contributor

Choose a reason for hiding this comment

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

@AdityaHegde I see you removed the sanitization – in that case, does it still need to traverse the AST or could it just propagate directly to the proto after it parses successfully?

Copy link
Collaborator

@AdityaHegde AdityaHegde Oct 15, 2025

Choose a reason for hiding this comment

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

We are removing comments to make things easy to parse. Also bracket balancing is not an error, we do it after traversing.

@mindspank mindspank changed the title feat: theming feat: theming backend Oct 8, 2025
Comment on lines 724 to 728
message ThemeCSS {
string primary = 1;
string secondary = 2;
map<string, string> properties = 3;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what do you think about updating the naming as below:

  1. With ThemeCSS, it's not actually clear that all these strings are colors. Consider naming it ThemeColors instead
  2. Call the map variables instead of properties (since they're CSS color variables, right?)
Suggested change
message ThemeCSS {
string primary = 1;
string secondary = 2;
map<string, string> properties = 3;
}
message ThemeColors {
string primary = 1;
string secondary = 2;
map<string, string> variables = 3;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ya, I was not a 100% sure what to name these.

Comment on lines 716 to 717
string primary_color_raw = 3;
string secondary_color_raw = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's easy, it would be nice to remove the legacy fields from the proto and just map them to the light property (guessing it'd make the UI handling simpler also?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point. Lets do that once UI has been updated? Otherwise main will be in bad state.

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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.