Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix: polynomial regular expression used on uncontrolled data (#7083)

sriram veeraghanta75a11ba31adc
diff --git a/packages/editor/src/core/helpers/common.ts b/packages/editor/src/core/helpers/common.ts
index 36075caf23..974b111d09 100644
--- a/packages/editor/src/core/helpers/common.ts
+++ b/packages/editor/src/core/helpers/common.ts
@@ -38,11 +38,10 @@ export const findTableAncestor = (node: Node | null): HTMLTableElement | null =>
return node as HTMLTableElement;
};
-export const getTrimmedHTML = (html: string) => {
- html = html.replace(/^(<p><\/p>)+/, "");
- html = html.replace(/(<p><\/p>)+$/, "");
- return html;
-};
+export const getTrimmedHTML = (html: string) =>
+ html
+ .replace(/^(?:<p><\/p>)+/g, "") // Remove from beginning
+ .replace(/(?:<p><\/p>)+$/g, ""); // Remove from end
export const isValidHttpUrl = (string: string): { isValid: boolean; url: string } => {
// List of potentially dangerous protocols to block