@hmcts/media-viewer 4.2.38-innerhtml-security-update → 4.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/cache/moment-npm-2.31.0-f6e03a269c-fd3708d46f.zip +0 -0
- package/.yarn/cache/moment-timezone-npm-0.6.4-78ea3bd92a-efa60fc46c.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/fesm2022/hmcts-media-viewer.mjs +16 -49
- package/fesm2022/hmcts-media-viewer.mjs.map +1 -1
- package/index.d.ts +1 -3
- package/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/package.tgz +0 -0
- package/.yarn/cache/moment-npm-2.30.1-1c51a5c631-ae42d876d4.zip +0 -0
- package/.yarn/cache/moment-timezone-npm-0.6.3-b95bcae468-55ae516386.zip +0 -0
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -3353,55 +3353,26 @@ class TextHighlightDirective {
|
|
|
3353
3353
|
highlightInputText(textToHighlight) {
|
|
3354
3354
|
this.resetHighlight();
|
|
3355
3355
|
this.textToHighlight = textToHighlight;
|
|
3356
|
-
const searchPattern = new RegExp(
|
|
3356
|
+
const searchPattern = new RegExp(textToHighlight, 'gi');
|
|
3357
3357
|
const hostElement = this.element.nativeElement;
|
|
3358
|
-
|
|
3358
|
+
if (hostElement.innerHTML.match(searchPattern)) {
|
|
3359
|
+
hostElement.innerHTML = hostElement.innerHTML
|
|
3360
|
+
.replace(searchPattern, this.highlightPattern('$&'));
|
|
3361
|
+
}
|
|
3359
3362
|
this.textToHighlight = undefined;
|
|
3360
3363
|
}
|
|
3361
3364
|
resetHighlight() {
|
|
3362
3365
|
const hostElement = this.element.nativeElement;
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
highlightTextNodes(hostElement, searchPattern) {
|
|
3369
|
-
const walker = document.createTreeWalker(hostElement, NodeFilter.SHOW_TEXT);
|
|
3370
|
-
const textNodes = [];
|
|
3371
|
-
let currentNode = walker.nextNode();
|
|
3372
|
-
while (currentNode) {
|
|
3373
|
-
textNodes.push(currentNode);
|
|
3374
|
-
currentNode = walker.nextNode();
|
|
3375
|
-
}
|
|
3376
|
-
textNodes.forEach((textNode) => this.highlightTextNode(textNode, searchPattern));
|
|
3377
|
-
}
|
|
3378
|
-
highlightTextNode(textNode, searchPattern) {
|
|
3379
|
-
const text = textNode.textContent || '';
|
|
3380
|
-
const matches = Array.from(text.matchAll(searchPattern));
|
|
3381
|
-
if (matches.length === 0) {
|
|
3382
|
-
return;
|
|
3383
|
-
}
|
|
3384
|
-
const fragment = document.createDocumentFragment();
|
|
3385
|
-
let currentIndex = 0;
|
|
3386
|
-
matches.forEach((match) => {
|
|
3387
|
-
const matchIndex = match.index || 0;
|
|
3388
|
-
const matchText = match[0];
|
|
3389
|
-
if (matchIndex > currentIndex) {
|
|
3390
|
-
fragment.appendChild(document.createTextNode(text.slice(currentIndex, matchIndex)));
|
|
3366
|
+
const searchPattern = new RegExp(this.highlightPattern('(.*?)'), 'gi');
|
|
3367
|
+
while (hostElement.innerHTML.match(searchPattern)) {
|
|
3368
|
+
const matchGroups = searchPattern.exec(hostElement.innerHTML);
|
|
3369
|
+
if (matchGroups) {
|
|
3370
|
+
hostElement.innerHTML = hostElement.innerHTML.replace(matchGroups[0], matchGroups[1]);
|
|
3391
3371
|
}
|
|
3392
|
-
const highlightElement = document.createElement('span');
|
|
3393
|
-
highlightElement.className = 'mvTextHighlight';
|
|
3394
|
-
highlightElement.textContent = matchText;
|
|
3395
|
-
fragment.appendChild(highlightElement);
|
|
3396
|
-
currentIndex = matchIndex + matchText.length;
|
|
3397
|
-
});
|
|
3398
|
-
if (currentIndex < text.length) {
|
|
3399
|
-
fragment.appendChild(document.createTextNode(text.slice(currentIndex)));
|
|
3400
3372
|
}
|
|
3401
|
-
textNode.replaceWith(fragment);
|
|
3402
3373
|
}
|
|
3403
|
-
|
|
3404
|
-
return
|
|
3374
|
+
highlightPattern(dynamicText) {
|
|
3375
|
+
return '<span class="mvTextHighlight">' + dynamicText + '</span>';
|
|
3405
3376
|
}
|
|
3406
3377
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.26", ngImport: i0, type: TextHighlightDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
3407
3378
|
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.26", type: TextHighlightDirective, isStandalone: false, selector: "[mvTextHighlight]", inputs: { textToHighlight: "textToHighlight" }, ngImport: i0 }); }
|
|
@@ -7972,14 +7943,12 @@ class GovUkLabelComponent {
|
|
|
7972
7943
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.26", ngImport: i0, type: GovUkLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
7973
7944
|
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.26", type: GovUkLabelComponent, isStandalone: false, selector: "mv-gov-label", inputs: { config: "config" }, ngImport: i0, template: `<h1 *ngIf="config.isPageHeading else noHeading">
|
|
7974
7945
|
<label *ngIf="config.label" [class]="config.classes + ' govuk-label'"
|
|
7975
|
-
[for]="config.id">
|
|
7976
|
-
{{ config.label }}
|
|
7946
|
+
[for]="config.id" [innerHTML]="config.label">
|
|
7977
7947
|
</label>
|
|
7978
7948
|
</h1>
|
|
7979
7949
|
<ng-template #noHeading>
|
|
7980
7950
|
<label *ngIf="config.label" [class]="config.classes + ' govuk-label'"
|
|
7981
|
-
[for]="config.id">
|
|
7982
|
-
{{ config.label }}
|
|
7951
|
+
[for]="config.id" [innerHTML]="config.label">
|
|
7983
7952
|
</label>
|
|
7984
7953
|
</ng-template>
|
|
7985
7954
|
`, isInline: true, dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
|
|
@@ -7990,14 +7959,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.26", ngImpo
|
|
|
7990
7959
|
selector: 'mv-gov-label',
|
|
7991
7960
|
template: `<h1 *ngIf="config.isPageHeading else noHeading">
|
|
7992
7961
|
<label *ngIf="config.label" [class]="config.classes + ' govuk-label'"
|
|
7993
|
-
[for]="config.id">
|
|
7994
|
-
{{ config.label }}
|
|
7962
|
+
[for]="config.id" [innerHTML]="config.label">
|
|
7995
7963
|
</label>
|
|
7996
7964
|
</h1>
|
|
7997
7965
|
<ng-template #noHeading>
|
|
7998
7966
|
<label *ngIf="config.label" [class]="config.classes + ' govuk-label'"
|
|
7999
|
-
[for]="config.id">
|
|
8000
|
-
{{ config.label }}
|
|
7967
|
+
[for]="config.id" [innerHTML]="config.label">
|
|
8001
7968
|
</label>
|
|
8002
7969
|
</ng-template>
|
|
8003
7970
|
`,
|