~ubuntu-branches/ubuntu/jaunty/squid3/jaunty-security

« back to all changes in this revision

Viewing changes to tools/cachemgr.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2008-07-21 09:20:31 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080721092031-bj8vog645lw6487u
Tags: 3.0.STABLE8-1
* Urgency high to meet freeze deadline

* New upstream release

* debian/patches/10-mgr_active_requests
  - Added upstream patch fixing delay_pool reporting in cachemgr.cgi

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
    printf("<HTML><HEAD><TITLE>Cache Manager Error</TITLE>\n");
421
421
    printf("<STYLE type=\"text/css\"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}--></STYLE></HEAD>\n");
422
422
    printf("<BODY><H1>Cache Manager Error</H1>\n");
423
 
    printf("<P>\n%s</P>\n", msg);
 
423
    printf("<P>\n%s</P>\n", html_quote(msg));
424
424
    print_trailer();
425
425
}
426
426
 
536
536
    if (!strchr(buf, '\t') || *buf == '\t') {
537
537
        /* nope, just text */
538
538
        snprintf(html, sizeof(html), "%s%s",
539
 
                 table_line_num ? "</table>\n<pre>" : "", buf);
 
539
                 table_line_num ? "</table>\n<pre>" : "", html_quote(buf));
540
540
        table_line_num = 0;
541
541
        return html;
542
542
    }
573
573
        l += snprintf(html + l, sizeof(html) - l, "<%s colspan=\"%d\" align=\"%s\">%s</%s>",
574
574
                      ttag, column_span,
575
575
                      is_header ? "center" : is_number(cell) ? "right" : "left",
576
 
                      cell, ttag);
 
576
                      html_quote(cell), ttag);
577
577
    }
578
578
 
579
579
    xfree(buf_copy);
584
584
    return html;
585
585
}
586
586
 
 
587
static const char *
 
588
munge_action_line(const char *_buf, cachemgr_request * req)
 
589
{
 
590
    static char html[2 * 1024];
 
591
    char *buf = xstrdup(_buf);
 
592
    char *x = buf;
 
593
    const char *action, *description;
 
594
    char *p;
 
595
 
 
596
    if ((p = strchr(x, '\n')))
 
597
       *p = '\0';
 
598
    action = xstrtok(&x, '\t');
 
599
    description = xstrtok(&x, '\t');
 
600
    if (!description)
 
601
       description = action;
 
602
    if (!action)
 
603
       return "";
 
604
    snprintf(html, sizeof(html), " <a href=\"%s\">%s</a>", menu_url(req, action), description);
 
605
    return html;
 
606
}
 
607
 
587
608
static int
588
609
read_reply(int s, cachemgr_request * req)
589
610
{
599
620
#endif
600
621
    /* interpretation states */
601
622
    enum {
602
 
        isStatusLine, isHeaders, isBodyStart, isBody, isForward, isEof, isForwardEof, isSuccess, isError
 
623
        isStatusLine, isHeaders, isActions, isBodyStart, isBody, isForward, isEof, isForwardEof, isSuccess, isError
603
624
    } istate = isStatusLine;
604
625
    int parse_menu = 0;
605
626
    const char *action = req->action;
694
715
                printf("<PRE>\n");
695
716
            }
696
717
 
 
718
            istate = isActions;
 
719
            /* yes, fall through, we do not want to loose the first line */
 
720
 
 
721
        case isActions:
 
722
            if (strncmp(buf, "action:", 7) == 0) {
 
723
                fputs(" ", stdout);
 
724
                fputs(munge_action_line(buf + 7, req), stdout);
 
725
                break;
 
726
            }
 
727
            if (parse_menu) {
 
728
                printf("<UL>\n");
 
729
            } else {
 
730
                printf("<HR noshade size=\"1px\">\n");
 
731
                printf("<PRE>\n");
 
732
            }
 
733
 
697
734
            istate = isBody;
698
735
            /* yes, fall through, we do not want to loose the first line */
699
736
 
714
751
             * 401 to .cgi because web server filters out all auth info. Thus we
715
752
             * disable authentication headers for now.
716
753
             */
717
 
            if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19))
718
 
 
719
 
                ;       /* skip */
 
754
            if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19));    /* skip */
720
755
            else
721
756
                fputs(buf, stdout);
722
757