From 95d4d3e5fb519ec5154b9404e1b2dcf6132f58c8 Mon Sep 17 00:00:00 2001 From: Charles Hu Date: Thu, 1 Aug 2024 06:43:03 -0400 Subject: [PATCH 1/2] Clean up tags Signed-off-by: Charles Hu --- .../src/converters-from-hdf/html/reverse-html-mapper.ts | 9 +++++++++ libs/hdf-converters/src/utils/global.ts | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts b/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts index eec852ba83..49b9757e02 100644 --- a/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts +++ b/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts @@ -24,6 +24,7 @@ import { IResultSeverity, IResultStatus } from './html-types'; +import {cleanTags} from '../../utils/global'; type InputData = { data: ContextualizedEvaluation | string; @@ -416,6 +417,14 @@ export class FromHDFToHTMLMapper { .map((control) => (control === 'unmapped' ? 'UM-1' : control)) .filter((control) => control !== 'Rev_4'); + // Clean up possible tags that may get passed from the OHDF file + result.hdf.wraps.title = result.hdf.wraps.title + ? cleanTags(result.hdf.wraps.title) + : ''; + result.hdf.wraps.desc = result.hdf.wraps.desc + ? cleanTags(result.hdf.wraps.desc) + : ''; + // Assign attributes return { ..._.set( diff --git a/libs/hdf-converters/src/utils/global.ts b/libs/hdf-converters/src/utils/global.ts index 98bdf97996..24634c1694 100644 --- a/libs/hdf-converters/src/utils/global.ts +++ b/libs/hdf-converters/src/utils/global.ts @@ -99,3 +99,9 @@ export function ensureContextualizedEvaluation( return contextualizeEvaluation(data); } } + +// Clean up any unescaped tags +export function cleanTags(text: string) { + return new DOMParser().parseFromString(text, 'text/html').documentElement + .textContent; +} From 9ea67146f49af757391727527951a0d4182d9bfb Mon Sep 17 00:00:00 2001 From: Charles Hu Date: Thu, 1 Aug 2024 16:01:34 -0400 Subject: [PATCH 2/2] Undo tag cleaning Signed-off-by: Charles Hu --- .../src/converters-from-hdf/html/reverse-html-mapper.ts | 9 --------- libs/hdf-converters/src/utils/global.ts | 6 ------ 2 files changed, 15 deletions(-) diff --git a/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts b/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts index 49b9757e02..eec852ba83 100644 --- a/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts +++ b/libs/hdf-converters/src/converters-from-hdf/html/reverse-html-mapper.ts @@ -24,7 +24,6 @@ import { IResultSeverity, IResultStatus } from './html-types'; -import {cleanTags} from '../../utils/global'; type InputData = { data: ContextualizedEvaluation | string; @@ -417,14 +416,6 @@ export class FromHDFToHTMLMapper { .map((control) => (control === 'unmapped' ? 'UM-1' : control)) .filter((control) => control !== 'Rev_4'); - // Clean up possible tags that may get passed from the OHDF file - result.hdf.wraps.title = result.hdf.wraps.title - ? cleanTags(result.hdf.wraps.title) - : ''; - result.hdf.wraps.desc = result.hdf.wraps.desc - ? cleanTags(result.hdf.wraps.desc) - : ''; - // Assign attributes return { ..._.set( diff --git a/libs/hdf-converters/src/utils/global.ts b/libs/hdf-converters/src/utils/global.ts index 24634c1694..98bdf97996 100644 --- a/libs/hdf-converters/src/utils/global.ts +++ b/libs/hdf-converters/src/utils/global.ts @@ -99,9 +99,3 @@ export function ensureContextualizedEvaluation( return contextualizeEvaluation(data); } } - -// Clean up any unescaped tags -export function cleanTags(text: string) { - return new DOMParser().parseFromString(text, 'text/html').documentElement - .textContent; -}