-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix/Project sitemap sharacter escaping #4923
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request involves removing debug logging in an API file, deleting two sitemap XML files, and enhancing the XML escaping utility function. The changes focus on cleaning up logging statements, removing existing sitemap files, and improving XML character sanitization by adding a mechanism to remove invalid control characters before escaping XML-specific special characters. Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (1)
src/helpers/xml.ts (1)
Line range hint
18-28
: Consider additional improvements for robustness.While the implementation is correct, consider these enhancements:
- Extract the regex pattern as a named constant for better maintainability
- Add input validation for
undefined
ornull
- Consider handling additional XML restrictions (e.g., Unicode surrogate pairs)
Here's a suggested implementation:
+ const INVALID_XML_CONTROL_CHARS = /[\x00-\x08\x0B\x0C\x0E-\x1F]/g; + export function escapeXml(unsafe: string): string { + if (unsafe == null) return ''; + // Remove invalid XML characters - const sanitized = unsafe.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ''); + const sanitized = unsafe.replace(INVALID_XML_CONTROL_CHARS, ''); // Escape XML special characters return sanitized .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }🧰 Tools
🪛 Biome (1.9.4)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
pages/api/generate-sitemap.ts
(0 hunks)public/sitemap/qf-sitemap.xml
(0 hunks)public/sitemap/users-sitemap.xml
(0 hunks)src/helpers/xml.ts
(1 hunks)
💤 Files with no reviewable changes (3)
- public/sitemap/qf-sitemap.xml
- public/sitemap/users-sitemap.xml
- pages/api/generate-sitemap.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/helpers/xml.ts
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
src/helpers/xml.ts (2)
11-15
: Well-documented changes!The documentation clearly describes the control character handling and provides comprehensive details about the function's behavior.
18-19
: Implementation looks good, static analysis warnings can be safely ignored.The regex pattern correctly handles control character removal. The static analysis warnings about control characters in the regex are false positives since this pattern is specifically designed to match and remove control characters in XML sanitization.
🧰 Tools
🪛 Biome (1.9.4)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
[error] 19-19: Unexpected control character in a regular expression.
Control characters are unusual and potentially incorrect inputs, so they are disallowed.
(lint/suspicious/noControlCharactersInRegex)
remove tested XML files, removing console logs, improving escape characters
Summary by CodeRabbit
Chores
Documentation
Maintenance