Przeglądaj źródła

Put html entity encoding back into terminal tag

Accidentally taken out when changing to observable events. It might be
be argued that the terminal tag's own dependency on `he.js` could be
shifted if it was left to the shell to sanitize input, but so long as
the commandline is the one calling the display to keep the last entered
command, html encoding should be the responsibility of the tag, not of
the shell. We probably don't want the shell also doing that call.
Probably.
Weiyi Lou 10 lat temu
rodzic
commit
c8cce74672
1 zmienionych plików z 5 dodań i 4 usunięć
  1. 5 4
      tags/terminal.tag

+ 5 - 4
tags/terminal.tag

@@ -126,7 +126,7 @@
   }
 
   preserveWhiteSpace(text) {
-    text = text.replace(/(?:\r\n|\r|\n)/g, '<br />')
+    text = text.replace(/\r\n|\r|\n/g, '<br />')
     // Search for tags or whitespace. Escape whitespace, leave tags.
     text = text.replace(/<[^<]+>|( )/g, function(match, group1) {
       if (group1 == " ") { return '&nbsp;' }
@@ -174,10 +174,11 @@
   })
 
   process() {
-    var prompt = this.visible ? this.prompt : '';
-    ev.trigger('disp_add', prompt + this.command.value + '\n')
-    ev.trigger('cmd_entered', this.command.value)
+    var prompt = this.visible ? this.prompt : ''
+    var command = he.encode(this.command.value)
     this.command.value = ''
+    ev.trigger('disp_add', prompt + command + '\n')
+    ev.trigger('cmd_entered', command)
   }
 </commandline>