@alfresco/aca-content 7.2.0-17759257923 → 7.2.0-17828792793

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.
@@ -10352,8 +10352,17 @@ class SearchResultsRowComponent {
10352
10352
  router;
10353
10353
  autoDownloadService;
10354
10354
  settings = inject(AppSettingsService);
10355
- highlightPrefix = "<span class='aca-highlight'>";
10356
- highlightPostfix = '</span>';
10355
+ highlightPrefix = `<span class="aca-highlight">`;
10356
+ highlightPostfix = `</span>`;
10357
+ highlightOpenEscapedRegex = /&lt;span class=(['"])aca-highlight\1&gt;/g;
10358
+ highlightCloseEscapedRegex = /&lt;\/span&gt;/g;
10359
+ highlightOpenRawRegex = /<span class=(['"])aca-highlight\1>/g;
10360
+ highlightCloseRawRegex = /<\/span>/g;
10361
+ escapeMap = {
10362
+ '&': '&amp;',
10363
+ '<': '&lt;',
10364
+ '>': '&gt;'
10365
+ };
10357
10366
  node;
10358
10367
  context;
10359
10368
  name$ = new BehaviorSubject('');
@@ -10413,16 +10422,24 @@ class SearchResultsRowComponent {
10413
10422
  break;
10414
10423
  }
10415
10424
  });
10416
- this.name$.next(name);
10417
- this.description$.next(description);
10418
- this.content$.next(content);
10425
+ const safeName = this.sanitizeAndHighlight(name);
10426
+ const safeDescription = this.sanitizeAndHighlight(description);
10427
+ const safeContent = this.sanitizeAndHighlight(content);
10428
+ this.name$.next(safeName);
10429
+ this.description$.next(safeDescription);
10430
+ this.content$.next(safeContent);
10419
10431
  this.nameStripped = this.stripHighlighting(name);
10432
+ this.titleStripped = this.stripHighlighting(title);
10420
10433
  this.descriptionStripped = this.stripHighlighting(description);
10421
10434
  this.contentStripped = this.stripHighlighting(content);
10422
- if (title !== name) {
10423
- this.title$.next(title ? ` ( ${title} )` : '');
10435
+ if (title && title !== name) {
10436
+ const safeTitle = this.sanitizeAndHighlight(` ( ${title} )`);
10437
+ this.title$.next(safeTitle);
10424
10438
  this.titleStripped = this.stripHighlighting(title);
10425
10439
  }
10440
+ else {
10441
+ this.title$.next('');
10442
+ }
10426
10443
  }
10427
10444
  showPreview(event) {
10428
10445
  event.stopPropagation();
@@ -10434,10 +10451,19 @@ class SearchResultsRowComponent {
10434
10451
  event.stopPropagation();
10435
10452
  this.store.dispatch(new NavigateToFolder(this.node));
10436
10453
  }
10437
- stripHighlighting(highlightedContent) {
10438
- return highlightedContent
10439
- ? highlightedContent.replace(new RegExp(this.highlightPrefix, 'g'), '').replace(new RegExp(this.highlightPostfix, 'g'), '')
10440
- : '';
10454
+ stripHighlighting(input) {
10455
+ if (!input) {
10456
+ return '';
10457
+ }
10458
+ return input.replace(this.highlightOpenRawRegex, '').replace(this.highlightCloseRawRegex, '');
10459
+ }
10460
+ sanitizeAndHighlight(value) {
10461
+ if (!value) {
10462
+ return '';
10463
+ }
10464
+ let escaped = value.replace(/[&<>]/g, (char) => this.escapeMap[char] ?? char);
10465
+ escaped = escaped.replace(this.highlightOpenEscapedRegex, this.highlightPrefix).replace(this.highlightCloseEscapedRegex, this.highlightPostfix);
10466
+ return escaped;
10441
10467
  }
10442
10468
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: SearchResultsRowComponent, deps: [{ token: i1.Store }, { token: i3.NodesApiService }, { token: i1$3.Router }, { token: i1$1.AutoDownloadService }], target: i0.ɵɵFactoryTarget.Component });
10443
10469
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: SearchResultsRowComponent, isStandalone: true, selector: "aca-search-results-row", inputs: { context: "context" }, host: { classAttribute: "aca-search-results-row" }, ngImport: i0, template: "<div class=\"aca-search-results-text\">\n <div class=\"search-file-name\">\n <span\n tabindex=\"0\"\n role=\"link\"\n *ngIf=\"isFile\"\n (click)=\"showPreview($event)\"\n (keyup.enter)=\"showPreview($event)\"\n class=\"aca-link aca-crop-text\"\n [title]=\"nameStripped\"\n [innerHTML]=\"name$ | async\"\n ></span>\n <span\n tabindex=\"0\"\n role=\"link\"\n *ngIf=\"!isFile\"\n (click)=\"navigate($event)\"\n (keyup.enter)=\"navigate($event)\"\n class=\"bold aca-link aca-crop-text\"\n [title]=\"nameStripped\"\n [innerHTML]=\"name$ | async\"\n ></span>\n <span\n data-automation-id=\"search-results-entry-title\"\n class=\"aca-crop-text\"\n [title]=\"titleStripped\"\n [innerHTML]=\"title$ | async\"\n ></span>\n </div>\n <div\n data-automation-id=\"search-results-entry-description\"\n class=\"aca-crop-text\"\n [title]=\"descriptionStripped\"\n [innerHTML]=\"description$ | async\"\n ></div>\n <div class=\"aca-result-location\">\n <aca-location-link [context]=\"context\" [showLocation]=\"true\" />\n </div>\n <div class=\"aca-result-content aca-crop-text\" [title]=\"contentStripped\" [innerHTML]=\"content$ | async\"></div>\n</div>\n<aca-datatable-cell-badges [node]=\"context.row.node\" />\n", styles: [".aca-search-results-row{display:flex;justify-content:space-between;align-items:center;padding:10px 0;width:inherit}.aca-search-results-row .aca-highlight{background:var(--theme-search-highlight-background-color)}.aca-search-results-row .aca-crop-text{overflow:hidden;text-overflow:ellipsis}.aca-search-results-row .aca-result-location{height:15px;padding-top:3px}.aca-search-results-row .aca-result-content{padding:0 5px;font-style:italic}.aca-search-results-row .aca-link{text-decoration:none;color:var(--theme-text-bold-color)}.aca-search-results-row .aca-location-link .adf-datatable-cell-value{padding:0;color:var(--theme-foreground-text-color)}.aca-search-results-row .aca-link:hover,.aca-search-results-row .aca-location-link .adf-datatable-cell-value:hover{color:var(--theme-primary-color);text-decoration:underline}.aca-search-results-row .adf-is-selected .aca-link:not(:hover),.aca-search-results-row .adf-is-selected .adf-datatable-cell-value:not(:hover){color:var(--theme-primary-color)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$4.AsyncPipe, name: "async" }, { kind: "component", type: LocationLinkComponent, selector: "aca-location-link", inputs: ["context", "showLocation"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "component", type: DatatableCellBadgesComponent, selector: "aca-datatable-cell-badges", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });