View | Details | Raw Unified | Return to bug 51359
Collapse All | Expand All

(-)modules/arch/win32/mod_win32.c (-6 / +18 lines)
Lines 433-438 Link Here
433
        char buffer[1024];
433
        char buffer[1024];
434
        apr_size_t bytes = sizeof(buffer);
434
        apr_size_t bytes = sizeof(buffer);
435
        apr_size_t i;
435
        apr_size_t i;
436
        apr_size_t pos;
436
437
437
        /* Need to peek into the file figure out what it really is...
438
        /* Need to peek into the file figure out what it really is...
438
         * ### aught to go back and build a cache for this one of these days.
439
         * ### aught to go back and build a cache for this one of these days.
Lines 469-487 Link Here
469
        }
470
        }
470
471
471
        /* Script or executable, that is the question...
472
        /* Script or executable, that is the question...
472
         * we check here also for '! so that .vbs scripts can work as CGI.
473
         * We check here also for '! so that .vbs scripts can work as CGI,
474
         * and //! to support .js scripts.
473
         */
475
         */
474
        if ((bytes >= 2) && ((buffer[0] == '#') || (buffer[0] == '\''))
476
        if ((bytes >= 2) && (buffer[1] == '!') 
475
                         && (buffer[1] == '!')) {
477
                && ((buffer[0] == '#') || (buffer[0] == '\''))) {
478
            pos = 2;
479
        } 
480
        else if ((bytes >= 3) && (buffer[2] == '!')
481
                && (buffer[0] == '/') && (buffer[1] == '/')) {
482
            pos = 3;
483
        } 
484
        else {
485
            pos = -1;
486
        }
487
        if (pos != -1) {
476
            /* Assuming file is a script since it starts with a shebang */
488
            /* Assuming file is a script since it starts with a shebang */
477
            for (i = 2; i < bytes; i++) {
489
            for (i = pos; i < bytes; i++) {
478
                if ((buffer[i] == '\r') || (buffer[i] == '\n')) {
490
                if ((buffer[i] == '\r') || (buffer[i] == '\n')) {
479
                    buffer[i] = '\0';
491
                    buffer[i] = '\0';
480
                    break;
492
                    break;
481
                }
493
                }
482
            }
494
            }
483
            if (i < bytes) {
495
            if (i < bytes) {
484
                interpreter = buffer + 2;
496
                interpreter = buffer + pos;
485
                while (apr_isspace(*interpreter)) {
497
                while (apr_isspace(*interpreter)) {
486
                    ++interpreter;
498
                    ++interpreter;
487
                }
499
                }
Lines 507-513 Link Here
507
    if (!interpreter) {
519
    if (!interpreter) {
508
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
520
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
509
                      "%s is not executable; ensure interpreted scripts have "
521
                      "%s is not executable; ensure interpreted scripts have "
510
                      "\"#!\" or \"'!\" first line", *cmd);
522
                      "\"#!\" or \"'!\" or \"//!\" first line", *cmd);
511
        return APR_EBADF;
523
        return APR_EBADF;
512
    }
524
    }
513
525

Return to bug 51359