Terminal bug fixes/improvements

UI Components for JSF
Post Reply
jcetkov
Posts: 2
Joined: 17 Apr 2015, 16:30

17 Apr 2015, 16:41

I did some fixes to terminal that includes:

addressing the scrolling (http://forum.primefaces.org/viewtopic.php?f=3&t=24355) - if the output of the command is multiline and goes beyond the visible area, it's not in view unless manually scrolled.

sanitizing input on the echoing of previous command (typing <script>alert('something')</script> won't cause popup and will be echoed correctly)

and also additional handle method, that allows the commands to output to the terminal while they are running via the socket component, not just once the commands ends (it feels weird for longer running commands when nothing is happening).

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Apr 2015, 09:56

Thank you, I think Thomas is reviewing already.

shikida
Posts: 35
Joined: 29 May 2013, 06:15

01 Oct 2015, 14:52

Hi

I need this component to scroll down, as any terminal does.

Is there any workaround for this problem already?

TIA

Leo

jcetkov
Posts: 2
Joined: 17 Apr 2015, 16:30

15 Dec 2015, 22:32

The changes in the PR are following

Code: Select all

 this.content.prevObject[0].scrollTop = this.content.prevObject[0].scrollHeight;
fixes and issue where if command outputted multiple lines of text, beyond the current visible window, the terminal didn't scroll down until there was a user input (key pressed)

Code: Select all

  $('#command' + outputid).text(this.input.val());
fixes an issue where the user input was not sanitized and echoed to the terminal, allowing to user insert something like <script> window.alert("something"); </script> producing a security hole (you can try this in the primefaces showcase mock osx)

Code: Select all

 handle: function (content) {
    var commandResponseContainer = $("<div></div>");
    commandResponseContainer.append('<div class="ui-terminal-command">' + content + "</div>").appendTo(this.content);
    this.content.prevObject[0].scrollTop = this.content.prevObject[0].scrollHeight;
}
allows the terminal to be used along with the <p:socket> to allow async output of text to the terminal for longer running commands

the other changes in the processCommand function are related to the handle function - without it the prompt would stay visible and the async output would appear above it, which is different from standard terminal - so the changes hide the prompt dialog on command submission and unhide it on final return from the command execution

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests