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

* fix: polynomial regular expression used on uncontrolled data

* fix: optimize the function to handle both operations
This commit is contained in:
sriram veeraghanta
2025-05-19 17:14:26 +05:30
committed by GitHub
parent 1fc3709731
commit 75a11ba31a

View File

@@ -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