You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds HTML entity encoding functionality and applies it to dynamically generated content. A new encodeHTML utility function is created to escape special characters, and it's used to encode title and description values before they're incorporated into meta tags, preventing potential injection vulnerabilities.
Changes
Cohort / File(s)
Summary
HTML Encoding Utility functions/utils.ts
New export function encodeHTML(html: string) that escapes HTML special characters (&, <, >, ', ") with their corresponding entities.
Dynamic Content Encoding functions/index.ts
Title and description are now passed through encodeHTML before use in dynamic meta tag construction; error handler typed as any.
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title 'fix meta tags' is directly related to the main change in the changeset. The pull request modifies how meta tags (specifically title and description) are constructed by adding HTML encoding to prevent XSS vulnerabilities and ensure proper rendering.
Docstring Coverage
✅ Passed
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch fix-meta-tags
No actionable comments were generated in the recent review. 🎉
🧹 Recent nitpick comments
functions/index.ts (2)
62-62: request.url is interpolated into an HTML attribute without encoding.
This is pre-existing, but request.url can contain " characters (e.g., in query params), which would break out of the content="..." attribute—the same class of issue this PR fixes for title/description. Consider applying encodeHTML here as well for consistency.
80-80: catch (err: any) — acceptable but consider unknown.
Using unknown is the stricter TypeScript idiom (catch (err: unknown)), with a narrowing check before accessing .message. That said, any is pragmatic here and this is a minor style point.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit