Skip to content

Commit

Permalink
remove html characters in preview
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ2LS committed Sep 30, 2024
1 parent cb67f9f commit f4f9ac0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions freedata_gui/src/components/chat_conversations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{{ details.unread_messages }} new
</span>
<br />
<small>{{ details.body ? details.body : '<file>' }}</small>
<small>{{ sanitizeBody(details.body) || '<file>' }}</small>
</div>
<div class="col-3 text-end">
<small>{{ getDateTime(details.timestamp) }}</small>
Expand All @@ -48,6 +48,7 @@
</template>

<script>
import DOMPurify from 'dompurify';
import { setActivePinia } from 'pinia';
import pinia from '../store/index';
import { useChatStore } from '../store/chatStore.js';
Expand Down Expand Up @@ -117,9 +118,13 @@ function startNewChat() {
chat.newChatMessage = "Hi there! Nice to meet you!";
}
function sanitizeBody(body) {
return body ? DOMPurify.sanitize(body, { ALLOWED_TAGS: [] }) : null;
}
export default {
setup() {
return { chat, newChatCall, chatSelected, setMessagesAsRead, processBeaconData, getDateTime, newChat, startNewChat };
return { chat, newChatCall, chatSelected, setMessagesAsRead, processBeaconData, getDateTime, newChat, startNewChat, sanitizeBody };
}
};
</script>

0 comments on commit f4f9ac0

Please sign in to comment.