Skip to content

Commit 40f9932

Browse files
authored
refactor: drop redundant console sanitize (#1890)
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
1 parent c199394 commit 40f9932

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/store/console/actions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Globals } from '@/globals'
33
import type { ConsoleEntry, ConsoleFilter, ConsoleState, PromptDialogButton, PromptDialogItemButton, PromptDialogItemText } from './types'
44
import type { RootState } from '../types'
55
import { SocketActions } from '@/api/socketActions'
6-
import DOMPurify from 'dompurify'
76
import { takeRightWhile } from 'lodash-es'
87

98
export const actions = {
@@ -43,13 +42,17 @@ export const actions = {
4342
* Add a console entry
4443
*/
4544
async onAddConsoleEntry ({ commit, dispatch }, payload: Omit<ConsoleEntry, 'id'>) {
46-
payload.message = DOMPurify.sanitize(payload.message).replace(/\r\n|\r|\n/g, '<br />')
45+
payload.message = payload.message
46+
.replace(/\r\n|\r|\n/g, '<br />')
47+
4748
if (!payload.time || payload.time <= 0) {
4849
payload.time = Date.now() / 1000 | 0
4950
}
51+
5052
if (!payload.type) {
5153
payload.type = 'response'
5254
}
55+
5356
if (payload.type === 'response' && payload.message.startsWith('// action:')) {
5457
payload.type = 'action'
5558
}
@@ -66,8 +69,7 @@ export const actions = {
6669
if (payload && payload.gcode_store) {
6770
const entries = payload.gcode_store
6871
.map((entry, index): ConsoleEntry => {
69-
const rawMessage = Globals.CONSOLE_RECEIVE_PREFIX + entry.message
70-
const message = DOMPurify.sanitize(rawMessage)
72+
const message = Globals.CONSOLE_RECEIVE_PREFIX + entry.message
7173
.replace(/\r\n|\r|\n/g, '<br />')
7274

7375
const type = (

0 commit comments

Comments
 (0)