From 618999f3cc7207a0f04a3837872b6c84696d8136 Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 5 Mar 2015 15:46:13 +0100 Subject: [PATCH 1/7] Issue #114: popup warning on tab/window close JS `window.onbeforeunload` handler was added, and it will be trigger if session is active. Reference: 6693512fde244cbb7f10e0033d4b4e5ec1b20e32 --- shellinabox/root_page.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/shellinabox/root_page.html b/shellinabox/root_page.html index 38bde27..41b6488 100644 --- a/shellinabox/root_page.html +++ b/shellinabox/root_page.html @@ -99,6 +99,16 @@ ''); } })(); + + // User warning on window close + window.onbeforeunload = function(e) { + if (typeof window.shellinabox.session != "undefined") { + return "Are you sure you want to leave this page?"; + } else { + return null; + } + } + --> @@ -107,7 +117,7 @@ correctly deal with the enclosing frameset (if any), if we do not do this --> - From 33813cd46d4016aea9dad6d628141570c7cb7756 Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 5 Mar 2015 16:15:12 +0100 Subject: [PATCH 2/7] Issue #245: Blank screen in Chrome 31.0.1650.57 Applied patch and fixed some formating. Patch: https://code.google.com/p/shellinabox/issues/detail?id=245#c5 --- shellinabox/vt100.jspp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index 6ec0efa..e5f31ab 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -175,7 +175,7 @@ function VT100(container) { } this.getUserSettings(); this.initializeElements(container); - this.maxScrollbackLines = 500; + this.maxScrollbackLines = 2000; this.npar = 0; this.par = [ ]; this.isQuestionMark = false; @@ -1157,8 +1157,12 @@ VT100.prototype.resizer = function() { // still get confused if somebody enters a character that is wider/narrower // than normal. This can happen if the browser tries to substitute a // characters from a different font. - this.cursor.style.width = this.cursorWidth + 'px'; - this.cursor.style.height = this.cursorHeight + 'px'; + if (this.cursorWidth > 0) { + this.cursor.style.width = this.cursorWidth + 'px'; + } + if (this.cursorHeight > 0) { + this.cursor.style.height = this.cursorHeight + 'px'; + } // Adjust height for one pixel padding of the #vt100 element. // The latter is necessary to properly display the inactive cursor. @@ -1531,8 +1535,20 @@ VT100.prototype.insertBlankLine = function(y, color, style) { }; VT100.prototype.updateWidth = function() { - this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/ - this.cursorWidth*this.scale); + // if the cursorWidth is zero, something is wrong. Try to get it some other way. + if (this.cursorWidth <= 0) { + if (this.cursor.clientWidth <= 0) { + // Rats, this.cursor.clientWidth is zero too. Best guess? + this.terminalWidth = 80; + } else { + // update the size. + this.cursorWidth = this.cursor.clientWidth; + this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale); + } + } else { + this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale); + } + return this.terminalWidth; }; From 821ee789c4077942e57d8cef0521e9bb484663f3 Mon Sep 17 00:00:00 2001 From: Ezra Buehler Date: Tue, 17 Dec 2013 13:01:54 +0100 Subject: [PATCH 3/7] No longer set HTTP Content-Length --- shellinabox/shell_in_a_box.jspp | 2 -- 1 file changed, 2 deletions(-) diff --git a/shellinabox/shell_in_a_box.jspp b/shellinabox/shell_in_a_box.jspp index 8fa2132..de7e5be 100644 --- a/shellinabox/shell_in_a_box.jspp +++ b/shellinabox/shell_in_a_box.jspp @@ -172,7 +172,6 @@ ShellInABox.prototype.sendRequest = function(request) { (this.session ? '&session=' + encodeURIComponent(this.session) : '&rooturl='+ encodeURIComponent(this.rooturl)); - request.setRequestHeader('Content-Length', content.length); request.onreadystatechange = function(shellInABox) { return function() { @@ -230,7 +229,6 @@ ShellInABox.prototype.sendKeys = function(keys) { '&height=' + this.terminalHeight + '&session=' +encodeURIComponent(this.session)+ '&keys=' + encodeURIComponent(keys); - request.setRequestHeader('Content-Length', content.length); request.onreadystatechange = function(shellInABox) { return function() { try { From 8e68059b5097a4bfbbdbb2ef2e49f1668a5bf55f Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 5 Mar 2015 17:10:55 +0100 Subject: [PATCH 4/7] Issue #202: "-_" keys don't not work in FF > 15 Added new keycodes for Firefox More info: https://code.google.com/p/shellinabox/issues/detail?id=202 Refernece: 49b538590ea57da76a0af895a23c521c9a4538be --- shellinabox/vt100.jspp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index e5f31ab..fcfb42e 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -2729,6 +2729,8 @@ VT100.prototype.handleKey = function(event) { case 123: /* F12 */ ch = '\u001B[24~'; break; case 144: /* Num Lock */ return; case 145: /* Scroll Lock */ return; + case 163: /* # for FF15 */ ch = this.applyModifiers(35, event); break; + case 173: /* - for FF15 */ ch = this.applyModifiers(45, event); break; case 186: /* ; */ ch = this.applyModifiers(59, event); break; case 187: /* = */ ch = this.applyModifiers(61, event); break; case 188: /* , */ ch = this.applyModifiers(44, event); break; @@ -2873,6 +2875,9 @@ VT100.prototype.fixEvent = function(event) { case 109: /* - -> _ */ u = 45; s = 95; break; case 111: /* / -> ? */ u = 47; s = 63; break; + case 163: /* # -> ~ FF15 */ u = 96; s = 126; break; + case 173: /* - -> _ FF15 */ u = 45; s = 95; break; + case 186: /* ; -> : */ u = 59; s = 58; break; case 187: /* = -> + */ u = 61; s = 43; break; case 188: /* , -> < */ u = 44; s = 60; break; From 7e0374b783f11ec29e4ead4b4f5e839961b45a77 Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 5 Mar 2015 17:17:41 +0100 Subject: [PATCH 5/7] Issue #180: Ever growing console occurs in iPad Patch taken from comments. More info: https://code.google.com/p/shellinabox/issues/detail?id=180 Refernece: 7ba55246327ad9934ed5d082a12b6cc73f381511 --- shellinabox/vt100.jspp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index fcfb42e..dc97181 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -1171,6 +1171,12 @@ VT100.prototype.resizer = function() { : (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight))-1; + + // Prevent ever growing consoles on iPad. + if (navigator.userAgent.match(/iPad/i) != null) { + height -= 1; + } + var partial = height % this.cursorHeight; this.scrollable.style.height = (height > 0 ? height : 0) + 'px'; this.padding.style.height = (partial > 0 ? partial : 0) + 'px'; From bd3f0bd9fdf3f50da29de21ca27c9482538f8212 Mon Sep 17 00:00:00 2001 From: KLuka Date: Tue, 13 Jan 2015 13:04:01 +0100 Subject: [PATCH 6/7] Debug info and minor fix on child process exit (service exit) * Added debug information when child process exits - pid of child process (service) - exit code (this should help for debuging issues related to "Session closed") * Fixed status checking from waitpid() when child process exits - before we were checking wrong variable (checks were allways true) - now we use correct status variable --- shellinabox/launcher.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index 68d8862..69e29e6 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -1616,7 +1616,8 @@ static void launcherDaemon(int fd) { int status; pid_t pid; while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { - if (WIFEXITED(pid) || WIFSIGNALED(pid)) { + debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status)); + if (WIFEXITED(status) || WIFSIGNALED(status)) { char key[32]; snprintf(&key[0], sizeof(key), "%d", pid); deleteFromHashMap(childProcesses, key); @@ -1636,7 +1637,8 @@ static void launcherDaemon(int fd) { break; } while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { - if (WIFEXITED(pid) || WIFSIGNALED(pid)) { + debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status)); + if (WIFEXITED(status) || WIFSIGNALED(status)) { char key[32]; snprintf(&key[0], sizeof(key), "%d", pid); deleteFromHashMap(childProcesses, key); From 4f0b949081bfd774a30d7c561e6317e6b3e5752b Mon Sep 17 00:00:00 2001 From: KLuka Date: Wed, 28 Jan 2015 20:54:56 +0100 Subject: [PATCH 7/7] =?UTF-8?q?IE=2011=20-=20This=20page=20can=E2=80=99t?= =?UTF-8?q?=20be=20displayed=20(Issue=20#262)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we are able to identify IE11 as MSIE browser and disable compresion. Patch taken from issue comments. https://code.google.com/p/shellinabox/issues/detail?id=262 --- libhttp/httpconnection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libhttp/httpconnection.c b/libhttp/httpconnection.c index a19ac3f..521d610 100644 --- a/libhttp/httpconnection.c +++ b/libhttp/httpconnection.c @@ -568,7 +568,7 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) { // also has difficulties with SSL connections that are being proxied. int ieBug = 0; const char *userAgent = getFromHashMap(&http->header, "user-agent"); - const char *msie = userAgent ? strstr(userAgent, "MSIE ") : NULL; + const char *msie = userAgent ? strstr(userAgent, "Trident") : NULL; if (msie) { ieBug++; }