Skip to content

Commit 062575f

Browse files
fix(vue): use isomorphic-dompurify
1 parent df8678c commit 062575f

File tree

4 files changed

+464
-359
lines changed

4 files changed

+464
-359
lines changed

packages/vue/examples/search-box-custom-suggestions/src/App.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<ul v-if="isOpen">
2424
<li
2525
v-for="suggestion in (suggestions || []).map(s => ({
26-
label: s.source.authors,
27-
value: s.source.authors,
26+
label: s.source && s.source.authors,
27+
value: s.source && s.source.authors,
2828
key: s._id,
2929
}))"
3030
v-bind="getItemProps({ item: suggestion })"
@@ -47,13 +47,13 @@
4747
class="result-list-container"
4848
>
4949
<template #renderItem="{ item }">
50-
<div
51-
:id="item._id"
52-
:key="item._id"
50+
<div
51+
:id="item._id"
52+
:key="item._id"
5353
class="flex book-content">
54-
<img
55-
:src="item.image"
56-
alt="Book Cover"
54+
<img
55+
:src="item.image"
56+
alt="Book Cover"
5757
class="book-image" >
5858
<div class="flex column justify-center ml20">
5959
<div class="book-header">{{ item.original_title }}</div>
@@ -72,13 +72,13 @@
7272
class="fas fa-star"
7373
/>
7474
</span>
75-
<span
75+
<span
7676
class="avg-rating"
7777
>({{ item.average_rating }} avg)</span
7878
>
7979
</div>
8080
</div>
81-
<span
81+
<span
8282
class="pub-year"
8383
>Pub {{ item.original_publication_year }}</span
8484
>

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"vue-no-ssr": "^1.1.0",
5555
"vue-slider-component": "next",
5656
"vue-types": "^5.0.2",
57-
"xss": "^1.0.11"
57+
"isomorphic-dompurify": "^1.12.0"
5858
},
5959
"peerDependencies": {
6060
"vue": "^3.1.0"

packages/vue/src/components/search/SearchBox.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Actions, helper, causes } from '@appbaseio/reactivecore';
33
import VueTypes from 'vue-types';
44
import hotkeys from 'hotkeys-js';
5-
import xss from 'xss';
5+
import { sanitize } from 'isomorphic-dompurify';
66
import { Remarkable } from 'remarkable';
77
import {
88
AI_LOCAL_CACHE_KEY,
@@ -216,7 +216,7 @@ const SearchBox = defineComponent({
216216
if (typeof renderItem === 'function') {
217217
const jsxEl = renderItem(newSuggestion);
218218
const innerValue = innerText(jsxEl);
219-
newSuggestion.value = xss(innerValue);
219+
newSuggestion.value = sanitize(innerValue);
220220
}
221221
return newSuggestion;
222222
}
@@ -1701,7 +1701,7 @@ const SearchBox = defineComponent({
17011701
return () => (
17021702
<div
17031703
style={{ display: 'flex' }}
1704-
innerHTML={xss(item.icon)}
1704+
innerHTML={sanitize(item.icon)}
17051705
/>
17061706
);
17071707
}
@@ -1710,7 +1710,7 @@ const SearchBox = defineComponent({
17101710
// When you change below also change the empty icon below
17111711
<img
17121712
style={{ maxWidth: '30px' }}
1713-
src={xss(item.iconURL)}
1713+
src={sanitize(item.iconURL)}
17141714
alt={item.value}
17151715
/>
17161716
);
@@ -1770,7 +1770,7 @@ const SearchBox = defineComponent({
17701770
const index
17711771
= indexOffset + itemIndex;
17721772
if (Array.isArray(item)) {
1773-
const sectionHtml = xss(
1773+
const sectionHtml = sanitize(
17741774
item[0].sectionLabel,
17751775
);
17761776
indexOffset += item.length - 1;

0 commit comments

Comments
 (0)