Skip to content

Commit 238adb4

Browse files
authored
[ENG-9255] Fix wrong < > & encoding (#742)
- Ticket: https://openscience.atlassian.net/browse/ENG-9242?focusedCommentId=92381 - Feature flag: n/a ## Purpose Fix wrong < > & encoding
1 parent f6109ee commit 238adb4

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/app/features/preprints/components/preprint-details/general-information/general-information.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h3>{{ 'preprints.preprintStepper.review.sections.authorAssertions.publicData' |
3838
<p>{{ 'preprints.preprintStepper.review.sections.authorAssertions.noData' | translate }}</p>
3939
}
4040
@case (ApplicabilityStatus.Unavailable) {
41-
{{ preprintValue.whyNoData }}
41+
{{ preprintValue.whyNoData | fixSpecialChar }}
4242
}
4343
@case (ApplicabilityStatus.Applicable) {
4444
@for (link of preprintValue.dataLinks; track $index) {
@@ -60,7 +60,7 @@ <h3>
6060
</p>
6161
}
6262
@case (ApplicabilityStatus.Unavailable) {
63-
{{ preprintValue.whyNoPrereg }}
63+
{{ preprintValue.whyNoPrereg | fixSpecialChar }}
6464
}
6565
@case (ApplicabilityStatus.Applicable) {
6666
@switch (preprintValue.preregLinkInfo) {
@@ -105,7 +105,7 @@ <h3>{{ 'preprints.details.supplementalMaterials' | translate }}</h3>
105105
<h3>{{ 'preprints.preprintStepper.review.sections.authorAssertions.conflictOfInterest' | translate }}</h3>
106106

107107
@if (preprintValue.hasCoi) {
108-
{{ preprintValue.coiStatement }}
108+
{{ preprintValue.coiStatement | fixSpecialChar }}
109109
} @else {
110110
<p>{{ 'preprints.preprintStepper.review.sections.authorAssertions.noCoi' | translate }}</p>
111111
}

src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ContributorsListComponent } from '@osf/shared/components/contributors-l
1717
import { IconComponent } from '@osf/shared/components/icon/icon.component';
1818
import { TruncatedTextComponent } from '@osf/shared/components/truncated-text/truncated-text.component';
1919
import { ResourceType } from '@osf/shared/enums/resource-type.enum';
20+
import { FixSpecialCharPipe } from '@osf/shared/pipes/fix-special-char.pipe';
2021
import {
2122
ContributorsSelectors,
2223
GetBibliographicContributors,
@@ -39,6 +40,7 @@ import { PreprintDoiSectionComponent } from '../preprint-doi-section/preprint-do
3940
IconComponent,
4041
AffiliatedInstitutionsViewComponent,
4142
ContributorsListComponent,
43+
FixSpecialCharPipe,
4244
],
4345
templateUrl: './general-information.component.html',
4446
styleUrl: './general-information.component.scss',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function replaceBadEncodedChars(text: string) {
2+
return text.replace(/&amp;/gi, '&').replace(/&lt;/gi, '<').replace(/&gt;/gi, '>');
3+
}

src/app/shared/services/meta-tags.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Meta, MetaDefinition, Title } from '@angular/platform-browser';
66

77
import { ENVIRONMENT } from '@core/provider/environment.provider';
88
import { PrerenderReadyService } from '@core/services/prerender-ready.service';
9+
import { replaceBadEncodedChars } from '@osf/shared/helpers/format-bad-encoding.helper';
910

1011
import { MetadataRecordFormat } from '../enums/metadata-record-format.enum';
1112
import { HeadTagDef } from '../models/meta-tags/head-tag-def.model';
@@ -274,7 +275,8 @@ export class MetaTagsService {
274275
const titleTag = headTags.find((tag) => tag.attrs.name === 'citation_title');
275276

276277
if (titleTag?.attrs.content) {
277-
this.title.setTitle(`${String(this.defaultMetaTags.siteName)} | ${String(titleTag.attrs.content)}`);
278+
const title = `${String(this.defaultMetaTags.siteName)} | ${String(titleTag.attrs.content)}`;
279+
this.title.setTitle(replaceBadEncodedChars(title));
278280
}
279281
}
280282
}

0 commit comments

Comments
 (0)