Skip to content

Commit 85810c0

Browse files
committed
pkp/pkp-lib#1660 removed escape html in favout of future implementation
1 parent 4048452 commit 85810c0

File tree

2 files changed

+11
-55
lines changed

2 files changed

+11
-55
lines changed

src/directives/stripUnsafeHtml.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,6 @@ const sanitizeConfig = {
44
USE_PROFILES: {html: true},
55
};
66

7-
/**
8-
* Strip HTML tags from a string
9-
* This will not run the content though DOM and remove all tags which is safe appraoch to remove all tags
10-
*
11-
* @param {string} dirtyString - The string to strip HTML tags from
12-
* @returns {string} The string with HTML tags removed
13-
*/
14-
export function stripHtmlTags(dirtyString) {
15-
const doc = new DOMParser().parseFromString(dirtyString, 'text/html');
16-
return doc.body.textContent || '';
17-
}
18-
19-
/**
20-
* Escapes HTML to display as plain text in the DOM, preserving all tags and attributes
21-
* This will not run the content though DOM and escape the html string which is safe of XSS attacks
22-
*
23-
* @param {string} dirtyString - The string to escape
24-
* @returns {string} The escaped string
25-
*/
26-
export function escapeHtml(dirtyString) {
27-
if (typeof dirtyString !== 'string') {
28-
return '';
29-
}
30-
31-
const div = document.createElement('div');
32-
div.appendChild(document.createTextNode(dirtyString));
33-
34-
return div.innerHTML;
35-
}
36-
377
export function sanitizeHtml(value) {
388
return DOMPurify.sanitize(value, sanitizeConfig);
399
}

src/managers/ReviewerRecommendationManager/reviewerRecommendationManagerStore.js

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import {computed} from 'vue';
33
import {useFetch} from '@/composables/useFetch';
44
import {useModal} from '@/composables/useModal';
55
import {useLocalize} from '@/composables/useLocalize';
6-
import {replaceLocaleParams} from '@/utils/i18n.js';
76
import {cloneDeep} from 'lodash';
87
import ReviewerRecommendationsEditModal from './ReviewerRecommendationsEditModal.vue';
9-
import {escapeHtml} from '@/directives/stripUnsafeHtml';
108
import {useUrl} from '@/composables/useUrl';
119
import {useForm} from '@/composables/useForm';
1210

@@ -24,11 +22,6 @@ export const useReviewerRecommendationManagerStore = defineComponentStore(
2422

2523
const items = computed({
2624
get: () => recommendations.value?.items || [],
27-
set: (newValue) => {
28-
if (recommendations.value) {
29-
recommendations.value.items = newValue;
30-
}
31-
},
3225
});
3326

3427
const itemsMax = computed(() => recommendations.value?.itemsMax || 0);
@@ -62,26 +55,24 @@ export const useReviewerRecommendationManagerStore = defineComponentStore(
6255
title: newStatus
6356
? t('manager.reviewerRecommendations.activate.title')
6457
: t('manager.reviewerRecommendations.deactivate.title'),
65-
message: replaceLocaleParams(
58+
message: t(
6659
item.status
67-
? t('manager.reviewerRecommendations.confirmDeactivate')
68-
: t('manager.reviewerRecommendations.confirmActivate'),
60+
? 'manager.reviewerRecommendations.confirmDeactivate'
61+
: 'manager.reviewerRecommendations.confirmActivate',
6962
{
70-
title: escapeHtml(localize(item.title)),
63+
title: localize(item.title),
7164
},
7265
),
7366
actions: [
7467
{
7568
label: t('common.yes'),
7669
isPrimary: true,
7770
callback: async (close) => {
78-
const success = await toggleStatus({
71+
await toggleStatus({
7972
id: item.id,
8073
newStatus,
8174
});
82-
if (success) {
83-
await fetchRecommendations();
84-
}
75+
await fetchRecommendations();
8576
close();
8677
},
8778
},
@@ -98,23 +89,18 @@ export const useReviewerRecommendationManagerStore = defineComponentStore(
9889
openDialog({
9990
name: 'delete',
10091
title: t('grid.action.deleteReviewerRecommendation'),
101-
message: replaceLocaleParams(
102-
t('manager.reviewerRecommendations.confirmDelete'),
103-
{
104-
title: escapeHtml(localize(item.title)),
105-
},
106-
),
92+
message: t('manager.reviewerRecommendations.confirmDelete', {
93+
title: localize(item.title),
94+
}),
10795
actions: [
10896
{
10997
label: t('common.yes'),
11098
isPrimary: true,
11199
callback: async (close) => {
112-
const success = await deleteRecommendation({
100+
await deleteRecommendation({
113101
id: item.id,
114102
});
115-
if (success) {
116-
await fetchRecommendations();
117-
}
103+
await fetchRecommendations();
118104
close();
119105
},
120106
},

0 commit comments

Comments
 (0)