@@ -124,8 +124,7 @@ function initWebSocket() {
124124 const success = response . success ;
125125 const cmd = response . command ;
126126 const tan = response . tan
127-
128- if ( success || typeof ( success ) === "undefined" ) {
127+ if ( success || typeof ( success ) == "undefined" ) {
129128 $ ( window . hyperion ) . trigger ( { type : "cmd-" + cmd , response : response } ) ;
130129 }
131130 else
@@ -137,48 +136,41 @@ function initWebSocket() {
137136 } else {
138137 const errorData = Array . isArray ( response . errorData ) ? response . errorData : [ ] ;
139138
140- const safeError = sanitizeForLog ( error ) ;
141- const safeErrorData = errorData . map ( ( item ) => sanitizeForLog ( item . description || "" ) ) ;
142-
143- console . log ( "[window.websocket::onmessage] " , safeError , ", Description:" , safeErrorData ) ;
139+ // Sanitize provided input
140+ const logError = error . replace ( / \n | \r / g , "" ) ;
141+ const logErrorData = JSON . stringify ( errorData ) . replace ( / [ \r \n \t ] / g , ' ' )
142+ console . log ( "[window.websocket::onmessage] " , logError , ", Description:" , logErrorData ) ;
144143
145144 $ ( window . hyperion ) . trigger ( {
146145 type : "error" ,
147146 reason : {
148147 cmd : cmd ,
149- message : safeError ,
150- details : safeErrorData
148+ message : error ,
149+ details : errorData . map ( ( item ) => item . description || "" )
151150 }
152151 } ) ;
153152 }
154153 }
155154 }
156155 catch ( exception_error ) {
157- const safeExceptionMessage = sanitizeForLog ( exception_error . message || 'Unknown error' ) ;
158- const safeExceptionStack = sanitizeForLog ( exception_error . stack || '' ) ;
159-
160- console . log ( "[window.websocket::onmessage] " , safeExceptionMessage ) ;
161-
156+ console . log ( "[window.websocket::onmessage] " , exception_error ) ;
162157 $ ( window . hyperion ) . trigger ( {
163158 type : "error" ,
164159 reason : {
165- message : $ . i18n ( "ws_processing_exception" ) + ": " + safeExceptionMessage ,
166- details : [ safeExceptionStack ]
160+ message : $ . i18n ( "ws_processing_exception" ) + ": " + exception_error . message ,
161+ details : [ exception_error . stack ]
167162 }
168163 } ) ;
169164 }
170165 } ;
171166
172167 window . websocket . onerror = function ( error ) {
173- const safeError = sanitizeForLog ( error ?. message || String ( error ) ) ;
174-
175- console . log ( "[window.websocket::onerror] " , safeError ) ;
176-
168+ console . log ( "[window.websocket::onerror] " , error ) ;
177169 $ ( window . hyperion ) . trigger ( {
178170 type : "error" ,
179171 reason : {
180- message : $ . i18n ( "ws_error_occured" ) ,
181- details : [ safeError ]
172+ message : $ . i18n ( "ws_error_occured" ) ,
173+ details : [ error ]
182174 }
183175 } ) ;
184176 } ;
0 commit comments