-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Chore: live server restructuring using esbuild #7256
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
base: preview
Are you sure you want to change the base?
Conversation
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
Co-Authored-By: sriram@plane.so <sriram@plane.so>
…rver-restructuring
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
*/ | ||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<script
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the issue, we will modify the function to repeatedly apply the regular expression replacement until no more matches are found. This ensures that all HTML tags, including nested or malformed ones, are completely removed. Additionally, we will use a more robust approach to handle edge cases and ensure that the function reliably extracts text content from HTML.
The updated function will:
- Use a loop to repeatedly apply the regular expression replacement until no changes occur.
- Ensure that all HTML tags are removed, leaving only the plain text content.
-
Copy modified lines R5-R11
@@ -4,5 +4,9 @@ | ||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); | ||
return textMatch || ""; | ||
// Use a regex to extract text between tags, applying it repeatedly to handle nested or malformed tags | ||
let previous; | ||
do { | ||
previous = html; | ||
html = html.replace(/<[^>]*>/g, ""); | ||
} while (html !== previous); | ||
return html || ""; | ||
}; |
*/ | ||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<script
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To address the issue, the function extractTextFromHTML
should be updated to repeatedly apply the regular expression replacement until no more replacements can be performed. This ensures that all instances of unsafe patterns are removed. Additionally, using a well-tested library like sanitize-html
is recommended for robust sanitization, but if external libraries are not an option, the repeated replacement approach is a viable alternative.
The fix involves:
- Modifying the
extractTextFromHTML
function to apply the regular expression replacement in a loop until the input stabilizes. - Ensuring that the function removes all HTML tags and nested patterns effectively.
-
Copy modified lines R20-R26
@@ -19,5 +19,9 @@ | ||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); | ||
return textMatch || ""; | ||
// Use a regex to extract text between tags repeatedly until no more replacements can be performed | ||
let previous; | ||
do { | ||
previous = html; | ||
html = html.replace(/<[^>]*>/g, ""); | ||
} while (html !== previous); | ||
return html || ""; | ||
}; |
|
||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
|
||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<script
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the issue, we need to ensure that all potentially unsafe HTML content, including nested or malformed tags, is removed. The best approach is to use a well-tested library like sanitize-html
to handle the sanitization process. This library is specifically designed to remove unsafe HTML content while preserving safe text. If using a library is not an option, we can implement a loop to repeatedly apply the regular expression until no more replacements occur, ensuring all tags are removed.
-
Copy modified lines R198-R199 -
Copy modified lines R201-R203
@@ -197,6 +197,8 @@ | ||
|
||
import sanitizeHtml from "sanitize-html"; | ||
|
||
export const extractTextFromHTML = (html: string): string => { | ||
// Use a regex to extract text between tags | ||
const textMatch = html.replace(/<[^>]*>/g, ""); | ||
return textMatch || ""; | ||
// Use sanitize-html to remove all HTML tags and return plain text | ||
const sanitizedText = sanitizeHtml(html, { allowedTags: [], allowedAttributes: {} }); | ||
return sanitizedText || ""; | ||
}; |
-
Copy modified lines R74-R75
@@ -73,3 +73,4 @@ | ||
"y-protocols": "^1.0.6", | ||
"yjs": "^13.6.20" | ||
"yjs": "^13.6.20", | ||
"sanitize-html": "^2.17.0" | ||
}, |
Package | Version | Security advisories |
sanitize-html (npm) | 2.17.0 | None |
Description
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References