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

(-)modules/arch/win32/mod_win32.c (-6 / +18 lines)
Lines 440-445 Link Here
440
        char buffer[1024];
440
        char buffer[1024];
441
        apr_size_t bytes = sizeof(buffer);
441
        apr_size_t bytes = sizeof(buffer);
442
        apr_size_t i;
442
        apr_size_t i;
443
        apr_size_t pos;
443
444
444
        /* Need to peek into the file figure out what it really is...
445
        /* Need to peek into the file figure out what it really is...
445
         * ### aught to go back and build a cache for this one of these days.
446
         * ### aught to go back and build a cache for this one of these days.
Lines 476-494 Link Here
476
        }
477
        }
477
478
478
        /* Script or executable, that is the question...
479
        /* Script or executable, that is the question...
479
         * we check here also for '! so that .vbs scripts can work as CGI.
480
         * We check here also for '! so that .vbs scripts can work as CGI,
481
         * and //! to support .js scripts.
480
         */
482
         */
481
        if ((bytes >= 2) && ((buffer[0] == '#') || (buffer[0] == '\''))
483
        if ((bytes >= 2) && (buffer[1] == '!') 
482
                         && (buffer[1] == '!')) {
484
                && ((buffer[0] == '#') || (buffer[0] == '\''))) {
485
            pos = 2;
486
        } 
487
        else if ((bytes >= 3) && (buffer[2] == '!')
488
                && (buffer[0] == '/') && (buffer[1] == '/')) {
489
            pos = 3;
490
        } 
491
        else {
492
            pos = -1;
493
        }
494
        if (pos != -1) {
483
            /* Assuming file is a script since it starts with a shebang */
495
            /* Assuming file is a script since it starts with a shebang */
484
            for (i = 2; i < bytes; i++) {
496
            for (i = pos; i < bytes; i++) {
485
                if ((buffer[i] == '\r') || (buffer[i] == '\n')) {
497
                if ((buffer[i] == '\r') || (buffer[i] == '\n')) {
486
                    buffer[i] = '\0';
498
                    buffer[i] = '\0';
487
                    break;
499
                    break;
488
                }
500
                }
489
            }
501
            }
490
            if (i < bytes) {
502
            if (i < bytes) {
491
                interpreter = buffer + 2;
503
                interpreter = buffer + pos;
492
                while (apr_isspace(*interpreter)) {
504
                while (apr_isspace(*interpreter)) {
493
                    ++interpreter;
505
                    ++interpreter;
494
                }
506
                }
Lines 514-520 Link Here
514
    if (!interpreter) {
526
    if (!interpreter) {
515
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
527
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
516
                      "%s is not executable; ensure interpreted scripts have "
528
                      "%s is not executable; ensure interpreted scripts have "
517
                      "\"#!\" or \"'!\" first line", *cmd);
529
                      "\"#!\" or \"'!\" or \"//!\" first line", *cmd);
518
        return APR_EBADF;
530
        return APR_EBADF;
519
    }
531
    }
520
532

Return to bug 51359