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:
parent
1fc3709731
commit
75a11ba31a
1 changed files with 4 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue