+2009-07-27 Markus Gutschke <markus@shellinabox.com>
+
+ * Use JavaScript redirection for attaching the missing slash to
+ the URL. This should make it easier to use reverse proxies. It was
+ already possible to run shellinaboxd behind a proxy, but a lot of
+ users got the configuration wrong.
+
2009-07-08 Markus Gutschke <markus@shellinabox.com>
* Optionally compress large responses, if the browser accepts
#define STDC_HEADERS 1
/* Most recent revision number in the version control system */
-#define VCS_REVISION "149"
+#define VCS_REVISION "152"
/* Version number of package */
#define VERSION "2.9"
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-VCS_REVISION=149
+VCS_REVISION=152
cat >>confdefs.h <<_ACEOF
dnl This is the one location where the authoritative version number is stored
AC_INIT(shellinabox, 2.9, markus@shellinabox.com)
-VCS_REVISION=149
+VCS_REVISION=152
AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system])
};
VT100.prototype.about = function() {
- alert("VT100 Terminal Emulator " + "2.9 (revision 149)" +
+ alert("VT100 Terminal Emulator " + "2.9 (revision 152)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com");
};
<title>Shell In A Box</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<script type="text/javascript"><!--
+ // Check that our URL is well-formed. Redirect to HTTPS if necessary
+ (function() {
+ var hasSSL = %s;
+ var path = document.location.pathname;
+ var proto = hasSSL ? 'https:' : 'http:';
+ if (path.match(/plain/) || !hasSSL) {
+ proto = 'http:';
+ }
+ path = path.replace(/\/+/, '/').replace(/\/$/, '');
+ if (!path.match(/(?:\/|\/plain)$/)) {
+ path += '/';
+ }
+ var url = proto + '//' + document.location.host + path;
+ if (document.location.search != '' &&
+ document.location.search != '?') {
+ url += document.location.search;
+ }
+ if (document.location.hash != '' &&
+ document.location.hash != '#') {
+ url += document.location.hash;
+ }
+ if (url != document.location.href) {
+ document.location.replace(url);
+ }
+ })();
+
// We would like to hide overflowing lines as this can lead to
// visually jarring results if the browser substitutes oversized
// Unicode characters from different fonts. Unfortunately, a bug
// provide a menu entry to switch between the two.
var newNode = document.createElement('li');
var isSecure;
- if (document.location.href != '') {
+ if (document.location.hash != '') {
isSecure = !this.nextUrl.match(/\?plain$/);
} else {
isSecure = this.nextUrl.match(/^https:/);
};
ShellInABox.prototype.about = function() {
- alert("Shell In A Box version " + "2.9 (revision 149)" +
+ alert("Shell In A Box version " + "2.9 (revision 152)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com" +
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
// provide a menu entry to switch between the two.
var newNode = document.createElement('li');
var isSecure;
- if (document.location.href != '') {
+ if (document.location.hash != '') {
isSecure = !this.nextUrl.match(/\?plain$/);
} else {
isSecure = this.nextUrl.match(/^https:/);
// Normalize the path info
const char *pathInfo = urlGetPathInfo(url);
- int trailingSlash = *pathInfo == '/';
while (*pathInfo == '/') {
pathInfo++;
}
}
int pathInfoLength = endPathInfo - pathInfo;
- // The root page should always have a trailing slash. If it doesn't do so,
- // the JavaScript code cannot easily find related resources.
- if (!pathInfoLength && !trailingSlash) {
- char *redir = stringPrintf(NULL,
- "HTTP/1.1 302 Temporary Relocation\r\n"
- "Connection: close\r\n"
- "Content-Length: 0\r\n"
- "Content-Type: text/html\r\n"
- "Location: %s/\r\n"
- "\r\n",
- urlGetURL(url));
- debug("Redirecting to %s/", urlGetURL(url));
- httpTransfer(http, redir, strlen(redir));
- } else if (!pathInfoLength ||
- (pathInfoLength == 5 && !memcmp(pathInfo, "plain", 5))) {
- // The root page either serves the AJAX application or redirects to the
- // secure HTTPS URL.
+ if (!pathInfoLength ||
+ (pathInfoLength == 5 && !memcmp(pathInfo, "plain", 5)) ||
+ (pathInfoLength == 6 && !memcmp(pathInfo, "secure", 6))) {
+ // The root page serves the AJAX application.
if (contentType &&
!strncasecmp(contentType, "application/x-www-form-urlencoded", 33)) {
// XMLHttpRequest carrying data between the AJAX application and the
// client session.
return dataHandler(http, arg, buf, len, url);
}
- if (enableSSL && !pathInfoLength && strcmp(urlGetProtocol(url), "https")) {
- httpSendReply(http, 200, "Shell In A Box",
- "<script type=\"text/javascript\"><!--\n"
- "document.location.replace("
- "document.location.href.replace(/^http:/,'https:'));\n"
- "--></script>\n"
- "<noscript>\n"
- "JavaScript must be enabled for ShellInABox\n"
- "</noscript>");
- } else {
- extern char rootPageStart[];
- extern char rootPageEnd[];
- serveStaticFile(http, "text/html; charset=utf-8",
- rootPageStart, rootPageEnd);
- }
+ extern char rootPageStart[];
+ extern char rootPageEnd[];
+ char *rootPage;
+ check(rootPage = malloc(rootPageEnd - rootPageStart + 1));
+ memcpy(rootPage, rootPageStart, rootPageEnd - rootPageStart);
+ rootPage[rootPageEnd - rootPageStart] = '\000';
+ char *html = stringPrintf(NULL, rootPage,
+ enableSSL ? "true" : "false");
+ httpSendReply(http, 200, "OK", html);
+ free(rootPage);
} else if (pathInfoLength == 8 && !memcmp(pathInfo, "beep.wav", 8)) {
// Serve the audio sample for the console bell.
extern char beepStart[];
};
VT100.prototype.about = function() {
- alert("VT100 Terminal Emulator " + "2.9 (revision 149)" +
+ alert("VT100 Terminal Emulator " + "2.9 (revision 152)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com");
};