fix: bad html filtering regexp
This commit is contained in:
parent
07106f9161
commit
7e9daf8a20
3 changed files with 16 additions and 16 deletions
|
|
@ -34,7 +34,7 @@ export const createSimilarString = (str: string) => {
|
|||
};
|
||||
|
||||
const fallbackCopyTextToClipboard = (text: string) => {
|
||||
var textArea = document.createElement("textarea");
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
|
||||
// Avoid scrolling to bottom
|
||||
|
|
@ -49,7 +49,7 @@ const fallbackCopyTextToClipboard = (text: string) => {
|
|||
try {
|
||||
// FIXME: Even though we are using this as a fallback, execCommand is deprecated 👎. We should find a better way to do this.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
|
||||
var successful = document.execCommand("copy");
|
||||
document.execCommand("copy");
|
||||
} catch (err) {}
|
||||
|
||||
document.body.removeChild(textArea);
|
||||
|
|
@ -117,9 +117,9 @@ export const getFirstCharacters = (str: string) => {
|
|||
* console.log(text); // Some text
|
||||
*/
|
||||
|
||||
export const stripHTML = (html: string) => {
|
||||
const strippedText = html.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, ""); // Remove script tags
|
||||
return strippedText.replace(/<[^>]*>/g, ""); // Remove all other HTML tags
|
||||
export const sanitizeHTML = (htmlString: string) => {
|
||||
const sanitizedText = DOMPurify.sanitize(htmlString, { ALLOWED_TAGS: [] }); // sanitize the string to remove all HTML tags
|
||||
return sanitizedText.trim(); // trim the string to remove leading and trailing whitespaces
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -130,7 +130,7 @@ export const stripHTML = (html: string) => {
|
|||
* console.log(text); // Some text
|
||||
*/
|
||||
|
||||
export const stripAndTruncateHTML = (html: string, length: number = 55) => truncateText(stripHTML(html), length);
|
||||
export const stripAndTruncateHTML = (html: string, length: number = 55) => truncateText(sanitizeHTML(html), length);
|
||||
|
||||
/**
|
||||
* @description: This function return number count in string if number is more than 100 then it will return 99+
|
||||
|
|
@ -172,10 +172,10 @@ export const getFetchKeysForIssueMutation = (options: {
|
|||
const ganttFetchKey = cycleId
|
||||
? { ganttFetchKey: CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), ganttParams) }
|
||||
: moduleId
|
||||
? { ganttFetchKey: MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), ganttParams) }
|
||||
: viewId
|
||||
? { ganttFetchKey: VIEW_ISSUES(viewId.toString(), viewGanttParams) }
|
||||
: { ganttFetchKey: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "", ganttParams) };
|
||||
? { ganttFetchKey: MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), ganttParams) }
|
||||
: viewId
|
||||
? { ganttFetchKey: VIEW_ISSUES(viewId.toString(), viewGanttParams) }
|
||||
: { ganttFetchKey: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "", ganttParams) };
|
||||
|
||||
return {
|
||||
...ganttFetchKey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue