Skip to content
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

[ESC-340] Fix Underline on text block #598

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Conversation

chiragchhatrala
Copy link
Collaborator

@chiragchhatrala chiragchhatrala commented Oct 18, 2024

Fixed #593

Summary by CodeRabbit

  • New Features

    • Added support for the <u> HTML tag, allowing text to be underlined in user-generated content.
  • Bug Fixes

    • Ensured that the updated configuration maintains the integrity of existing allowed HTML elements.

Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes in this pull request involve updating the configuration for HTMLPurifier in the api/config/purify.php file. The main modification is the inclusion of the <u> HTML element in the HTML.Allowed configuration, allowing underlined text to be preserved during the HTML filtering process. Other settings in the configuration remain unchanged.

Changes

File Change Summary
api/config/purify.php Updated HTML.Allowed to include the <u> tag, allowing underlined text in the filtered output.

Assessment against linked issues

Objective Addressed Explanation
Retain underline formatting in text blocks (#593)

🐰 In the garden where words take flight,
Underlines dance in the soft moonlight.
With a flick of a tag, they twirl and play,
Saving the magic, come what may!
Hooray for the changes, let the text shine bright! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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: 0

🧹 Outside diff range and nitpick comments (2)
api/config/purify.php (2)

43-43: Approve change and suggest minor improvement

The addition of the 'u' tag to the 'HTML.Allowed' configuration successfully addresses the issue of underline formatting not being saved in text blocks. This change aligns perfectly with the PR objectives and should resolve the problem described in issue #593.

For improved clarity and maintainability, consider adding a comment explaining the purpose of including the 'u' tag. This will help future developers understand the reasoning behind this specific configuration. Here's a suggested implementation:

-            'HTML.Allowed' => 'h1,h2,b,u,strong,i,em,a[href|title],ul,ol,li,p,br,span,*[style]',
+            'HTML.Allowed' => 'h1,h2,b,u,strong,i,em,a[href|title],ul,ol,li,p,br,span,*[style]', // 'u' tag included to allow underline formatting

Line range hint 102-106: Consider removing commented-out code

To improve code cleanliness and reduce potential confusion for future developers, consider removing the commented-out serializer configuration at the end of the file. If this alternative configuration is important to keep for reference, it might be better to document it elsewhere, such as in a README or configuration guide.

Here's the suggested change:

-    // 'serializer' => [
-    //    'disk' => env('FILESYSTEM_DISK', 'local'),
-    //    'path' => 'purify',
-    //    'cache' => \Stevebauman\Purify\Cache\FilesystemDefinitionCache::class,
-    // ],

If you decide to keep this commented code, please add a comment explaining why it's being kept and under what circumstances it might be used.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e737108 and adc040c.

📒 Files selected for processing (1)
  • api/config/purify.php (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
api/config/purify.php (2)

Line range hint 1-108: Summary and Next Steps

This change effectively addresses the issue of underline formatting not being saved in text blocks by adding the 'u' tag to the HTMLPurifier configuration. The modification is minimal and focused, which is positive.

To ensure the change is fully validated and integrated:

  1. Implement the suggested verification steps to check for any security implications or unintended effects.
  2. Update or add relevant tests to cover the new behavior.
  3. Perform thorough manual testing across the application.
  4. Consider the suggested code cleanliness improvements.

Once these steps are completed and no issues are found, this change should be ready for merging.


43-43: Verify security implications and test thoroughly

While the addition of the 'u' tag is a minimal change that addresses the specific issue, it's important to ensure it doesn't introduce any security vulnerabilities or unintended side effects.

Please run the following verification steps:

  1. Security check:

  2. Usage verification:

  3. Test coverage:

After running these checks, please ensure to:

  1. Review any security-related findings and assess their relevance to this change.
  2. Update any custom HTML purification logic if necessary.
  3. Add or update tests to cover the new behavior, especially focusing on the preservation of underline formatting.
  4. Perform thorough manual testing to verify that underline formatting is correctly saved and displayed across different parts of the application.

@JhumanJ JhumanJ merged commit 469031c into main Oct 21, 2024
5 checks passed
@JhumanJ JhumanJ deleted the ESC-340---underline-text branch October 21, 2024 15:24
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.

[BUG] Underline in Text Block Not Saved
2 participants