--- modules/arch/win32/mod_win32.c (revision 1127376) +++ modules/arch/win32/mod_win32.c (working copy) @@ -433,6 +433,7 @@ char buffer[1024]; apr_size_t bytes = sizeof(buffer); apr_size_t i; + apr_size_t pos; /* Need to peek into the file figure out what it really is... * ### aught to go back and build a cache for this one of these days. @@ -469,19 +470,30 @@ } /* Script or executable, that is the question... - * we check here also for '! so that .vbs scripts can work as CGI. + * We check here also for '! so that .vbs scripts can work as CGI, + * and //! to support .js scripts. */ - if ((bytes >= 2) && ((buffer[0] == '#') || (buffer[0] == '\'')) - && (buffer[1] == '!')) { + if ((bytes >= 2) && (buffer[1] == '!') + && ((buffer[0] == '#') || (buffer[0] == '\''))) { + pos = 2; + } + else if ((bytes >= 3) && (buffer[2] == '!') + && (buffer[0] == '/') && (buffer[1] == '/')) { + pos = 3; + } + else { + pos = -1; + } + if (pos != -1) { /* Assuming file is a script since it starts with a shebang */ - for (i = 2; i < bytes; i++) { + for (i = pos; i < bytes; i++) { if ((buffer[i] == '\r') || (buffer[i] == '\n')) { buffer[i] = '\0'; break; } } if (i < bytes) { - interpreter = buffer + 2; + interpreter = buffer + pos; while (apr_isspace(*interpreter)) { ++interpreter; } @@ -507,7 +519,7 @@ if (!interpreter) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "%s is not executable; ensure interpreted scripts have " - "\"#!\" or \"'!\" first line", *cmd); + "\"#!\" or \"'!\" or \"//!\" first line", *cmd); return APR_EBADF; }