Bläddra i källkod

frontend: add html escaping to toast's text

wangweimin 4 år sedan
förälder
incheckning
66a69bacea
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1 1
      webiojs/src/handlers/toast.ts
  2. 1 1
      webiojs/src/utils.ts

+ 1 - 1
webiojs/src/handlers/toast.ts

@@ -11,7 +11,7 @@ export class ToastHandler implements CommandHandler {
     handle_message(msg: Command) {
         let spec = msg.spec;
         let toast = Toastify({
-            text: spec.content,
+            text: Mustache.escape(spec.content),
             duration: spec.duration === 0 ? -1 : spec.duration,  // -1 for permanent toast
             close: spec.duration === 0,//To show the close icon or not
             gravity: "top", // `top` or `bottom`

+ 1 - 1
webiojs/src/utils.ts

@@ -141,7 +141,7 @@ export function openApp(name: string, new_window: boolean) {
 
 export function error_alert(text: string, duration: number = 1.5) {
     Toastify({
-        text: text,
+        text: Mustache.escape(text),
         duration: duration * 1000,
         gravity: "top",
         position: 'center',