Skip to content

Comments

feat: add quote text, remove risky style tag#1672

Merged
MrgSub merged 3 commits intoMail-0:stagingfrom
retrogtx:quote
Jul 8, 2025
Merged

feat: add quote text, remove risky style tag#1672
MrgSub merged 3 commits intoMail-0:stagingfrom
retrogtx:quote

Conversation

@retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Jul 8, 2025

image

also removes the style tag from allowedTags which is risky

Summary by CodeRabbit

  • New Features

    • Quoted sections in emails (such as blockquotes and Gmail quotes) are now collapsed by default and can be expanded by clicking "Show quoted text."
    • Collapsible quoted sections are styled to match the current theme (dark or light).
  • Style

    • Improved visual styling for collapsible quoted sections in emails.
    • Mail content container now allows scrolling with visible scrollbars when content overflows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Walkthrough

The update modifies the email HTML sanitizer by removing the 'style' tag from allowed tags and adds a function to wrap quoted email sections (like blockquotes and Gmail quotes) in collapsible elements with a "Show quoted text" summary. Inline CSS is used to style these collapsible sections, adapting to light or dark themes. Additionally, the mail content container's CSS overflow behavior is changed from hidden to scroll.

Changes

File(s) Change Summary
apps/server/src/lib/email-processor.ts Removed 'style' from allowed HTML tags; added collapseQuoted function to wrap quoted sections in collapsible UI with inline styles adapting to theme; replaced extensive allowedStyles with simpler inline CSS; introduced theme normalization and isDarkTheme boolean.
apps/mail/components/mail/mail-content.tsx Changed mail content container's CSS overflow from overflow-hidden to overflow-scroll to enable scrolling of overflow content.

Sequence Diagram(s)

sequenceDiagram
    participant EmailHTML as Raw Email HTML
    participant Sanitizer as HTML Sanitizer
    participant Processor as Email Processor
    participant Output as Processed HTML

    EmailHTML->>Sanitizer: Remove disallowed tags (including 'style')
    Sanitizer->>Processor: Sanitized HTML
    Processor->>Processor: collapseQuoted() wraps blockquotes/gmail_quote in <details>
    Processor->>Output: Final processed HTML with collapsible quoted text
Loading

Possibly related PRs

Poem

In the warren, code’s refined,
Quoted text now hides behind—
A toggle neat, with style discreet,
No style tags in sight to find.
Rabbits cheer, with ears upright,
For emails now are clean and light!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afcdb98 and 7d4b9ca.

📒 Files selected for processing (2)
  • apps/mail/components/mail/mail-content.tsx (1 hunks)
  • apps/server/src/lib/email-processor.ts (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/mail/components/mail/mail-content.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/server/src/lib/email-processor.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/server/src/lib/email-processor.ts (1)

115-116: Consider adding error handling for selector operations.

The function calls could potentially fail if the DOM structure is malformed. Consider wrapping these calls in try-catch blocks to prevent the entire email processing from failing due to quote processing errors.

-collapseQuoted('blockquote');
-collapseQuoted('.gmail_quote');
+try {
+  collapseQuoted('blockquote');
+  collapseQuoted('.gmail_quote');
+} catch (error) {
+  console.warn('Failed to collapse quoted text:', error);
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0113d0 and e709f2e.

📒 Files selected for processing (1)
  • apps/server/src/lib/email-processor.ts (3 hunks)
🔇 Additional comments (2)
apps/server/src/lib/email-processor.ts (2)

17-17: Excellent security improvement!

Removing the 'style' tag from allowed HTML tags is a significant security enhancement that prevents potential XSS attacks through malicious CSS injection while maintaining necessary styling capabilities through the allowedStyles configuration.


189-206: Well-structured CSS with proper theme support.

The CSS styling is well-implemented with:

  • Proper theme-based color adaptation
  • Good accessibility considerations (hiding default markers, proper cursor styling)
  • Consistent spacing and visual hierarchy

The implementation correctly handles both light and dark themes while maintaining good UX.

retrogtx and others added 2 commits July 8, 2025 11:30
…e email HTML processing by allowing additional HTML tags in sanitizer.
@MrgSub MrgSub merged commit c3ec592 into Mail-0:staging Jul 8, 2025
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jul 23, 2025
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.

4 participants