Skip to content

Commit

Permalink
sanitize html on v-html (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ungarson authored May 6, 2022
1 parent d317ef6 commit 0452ec1
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 15 deletions.
262 changes: 258 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"json-view": "^0.4.0",
"null": "^2.0.0",
"redoc": "^2.0.0-rc.65",
"sanitize-html": "^2.7.0",
"v-clipboard": "^2.2.2",
"vue": "^2.6.10",
"vue-codemirror": "^4.0.6",
Expand Down
12 changes: 7 additions & 5 deletions src/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<span class="text--secondary hash">Contracts</span>
<span class="text--secondary" style="font-size: 20px">&nbsp;&nbsp;</span>
<span v-if="item.body.alias">{{ item.body.alias }}</span>
<span v-else v-html="helpers.shortcut(item.value)"></span>
<span v-else v-html="sanitizeHtml(helpers.shortcut(item.value))"></span>
</template>
<template v-else-if="item.type === 'operation'">
<span class="text--secondary hash">Operations</span>
Expand All @@ -69,7 +69,7 @@
>
<span
v-else
v-html="helpers.shortcut(item.body.destination)"
v-html="sanitizeHtml(helpers.shortcut(item.body.destination))"
class="text--secondary"
></span>
<span class="text--secondary" style="font-size: 20px">&nbsp;&nbsp;</span>
Expand All @@ -80,7 +80,7 @@
<span v-else-if="item.body.kind === 'origination'"
>origination</span
>
<span v-else v-html="helpers.shortcut(item.value)"></span>
<span v-else v-html="sanitizeHtml(helpers.shortcut(item.value))"></span>
</template>
<template v-else-if="item.type === 'bigmapdiff'">
<span class="text--secondary hash">Big_map {{ item.body.ptr }}</span>
Expand All @@ -96,7 +96,7 @@
<span class="text--secondary hash">Tokens</span>
<span class="text--secondary" style="font-size: 20px">&nbsp;&nbsp;</span>
<span v-if="item.body.name">{{ item.body.name }}</span>
<span v-else v-html="helpers.shortcut(item.value)"></span>
<span v-else v-html="sanitizeHtml(helpers.shortcut(item.value))"></span>
</template>
<template v-if="item.type === 'recent'">
<span v-if="item.body.alias">{{ item.body.alias }}</span>
Expand Down Expand Up @@ -152,7 +152,7 @@
].includes(item.body.found_by) &&
item.highlights[item.body.found_by]
"
v-html="item.highlights[item.body.found_by][0]"
v-html="sanitizeHtml(item.highlights[item.body.found_by][0])"
></span>
</v-list-item-action-text>
<v-list-item-action-text>
Expand Down Expand Up @@ -186,6 +186,7 @@ import {
import {SEARCH_TABS} from "../constants/searchTabs";
import { isKT1Address, isOperationHash } from "../utils/tz";
import waitUntil from "async-wait-until";
import sanitizeHtml from 'sanitize-html';
export default {
props: {
Expand Down Expand Up @@ -219,6 +220,7 @@ export default {
},
methods: {
...mapActions(["showError"]),
sanitizeHtml,
handleSearchBoxFocus() {
this.isFocused = true;
},
Expand Down
Loading

0 comments on commit 0452ec1

Please sign in to comment.