Skip to content

Commit

Permalink
fix: prevent HTML injection on no search result page and account over…
Browse files Browse the repository at this point in the history
…view (#1575)
  • Loading branch information
shauke committed Jan 16, 2024
1 parent c99e1d0 commit 3066250
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
Expand Up @@ -2,7 +2,7 @@
<h1
[innerHTML]="
'account.overview.personal_message_b2b.text'
| translate : { '0': user.firstName + '&nbsp;' + user.lastName, '1': customer.companyName }
| translate : { '0': user.firstName + '&nbsp;' + user.lastName, '1': customer.companyName | htmlEncode }
"
data-testing-id="personal-message-b2b"
></h1>
Expand Down
Expand Up @@ -10,6 +10,7 @@ import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive';
import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { Customer } from 'ish-core/models/customer/customer.model';
import { User } from 'ish-core/models/user/user.model';
import { HtmlEncodePipe } from 'ish-core/pipes/html-encode.pipe';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { RoleToggleModule } from 'ish-core/role-toggle.module';
import { OrderWidgetComponent } from 'ish-shared/components/order/order-widget/order-widget.component';
Expand Down Expand Up @@ -38,6 +39,7 @@ describe('Account Overview Component', () => {
MockComponent(OrderWidgetComponent),
MockDirective(AuthorizationToggleDirective),
MockDirective(ServerHtmlDirective),
MockPipe(HtmlEncodePipe),
MockPipe(ServerSettingPipe, () => true),
],
imports: [FeatureToggleModule.forTesting(), RoleToggleModule.forTesting(), TranslateModule.forRoot()],
Expand Down
Expand Up @@ -11,7 +11,10 @@ <h1 class="h2">{{ 'search.noResult.heading' | translate }}</h1>
<ish-content-include includeId="include.searchnoresult.content.top.pagelet2-Include" />
</div>

<p class="no-search-result-title" [innerHTML]="'search.noResult.message' | translate : { '0': searchTerm }"></p>
<p
class="no-search-result-title"
[innerHTML]="'search.noResult.message' | translate : { '0': searchTerm | htmlEncode }"
></p>

<div class="search-container main-search-container">
<ish-search-box
Expand Down
@@ -1,7 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { MockComponent, MockPipe } from 'ng-mocks';

import { HtmlEncodePipe } from 'ish-core/pipes/html-encode.pipe';
import { ContentIncludeComponent } from 'ish-shared/cms/components/content-include/content-include.component';
import { BreadcrumbComponent } from 'ish-shared/components/common/breadcrumb/breadcrumb.component';
import { SearchBoxComponent } from 'ish-shared/components/search/search-box/search-box.component';
Expand All @@ -21,6 +22,7 @@ describe('Search No Result Component', () => {
MockComponent(BreadcrumbComponent),
MockComponent(ContentIncludeComponent),
MockComponent(SearchBoxComponent),
MockPipe(HtmlEncodePipe, value => value),
SearchNoResultComponent,
],
}).compileComponents();
Expand Down
2 changes: 1 addition & 1 deletion src/styles/pages/category/search-result.scss
Expand Up @@ -15,7 +15,7 @@

.no-search-result-title {
span {
font-size: $font-size-lg;
font-family: $font-family-bold;
}
}

Expand Down

0 comments on commit 3066250

Please sign in to comment.