X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgi.c;h=2da5ab3d564932bf4f138e808937394f6fd4d541;hp=2bb6a37369728e131682fea6a2d7e387fcc84f63;hb=bc635cfc433ad1870057fd56b2fd0f2602c3f055;hpb=eaf38167c9a21326865db5cbb021b11abdfbc496 diff --git a/cgi.c b/cgi.c index 2bb6a373..2da5ab3d 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.80 2006/12/08 14:45:32 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.83 2006/12/17 19:35:19 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,16 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.80 2006/12/08 14:45:32 fabiankeil Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.83 2006/12/17 19:35:19 fabiankeil + * Escape ampersand in Privoxy menu. + * + * Revision 1.82 2006/12/17 17:53:39 fabiankeil + * Suppress the toggle link if remote toggling is disabled. + * + * Revision 1.81 2006/12/09 13:49:16 fabiankeil + * Fix configure option --disable-toggle. + * Thanks to Peter Thoenen for reporting this. + * * Revision 1.80 2006/12/08 14:45:32 fabiankeil * Don't lose the FORCE_PREFIX in case of * connection problems. Fixes #612235. @@ -557,7 +567,7 @@ static const struct cgi_dispatcher cgi_dispatchers[] = { { "show-status", cgi_show_status, #ifdef FEATURE_CGI_EDIT_ACTIONS - "View & change the current configuration", + "View & change the current configuration", #else "View the current configuration", #endif @@ -1065,7 +1075,7 @@ char get_char_param(const struct map *parameters, ch = *(lookup(parameters, param_name)); if ((ch >= 'a') && (ch <= 'z')) { - ch = ch - 'a' + 'A'; + ch = (char)(ch - 'a' + 'A'); } return ch; @@ -1197,7 +1207,7 @@ jb_err get_number_param(struct client_state *csp, return JB_ERR_CGI_PARAMS; } - ch -= '0'; + ch = (char)(ch - '0'); /* Note: * @@ -1211,7 +1221,7 @@ jb_err get_number_param(struct client_state *csp, return JB_ERR_CGI_PARAMS; } - value = value * 10 + ch; + value = value * 10 + (unsigned)ch; } /* Success */ @@ -1551,7 +1561,7 @@ jb_err cgi_error_unknown(struct client_state *csp, rsp->head_length = 0; rsp->is_static = 0; - sprintf(errnumbuf, "%d", error_to_report); + snprintf(errnumbuf, sizeof(errnumbuf), "%d", error_to_report); rsp->body = malloc(strlen(body_prefix) + strlen(errnumbuf) + strlen(body_suffix) + 1); if (rsp->body == NULL) @@ -1794,7 +1804,7 @@ struct http_response *finish_http_response(struct http_response *rsp) /* * Fill in the HTTP Status */ - sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK"); + snprintf(buf, sizeof(buf), "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK"); err = enlist_first(rsp->headers, buf); /* @@ -1806,7 +1816,7 @@ struct http_response *finish_http_response(struct http_response *rsp) } if (!err) { - sprintf(buf, "Content-Length: %d", (int)rsp->content_length); + snprintf(buf, sizeof(buf), "Content-Length: %d", (int)rsp->content_length); err = enlist(rsp->headers, buf); } @@ -2295,7 +2305,7 @@ struct map *default_exports(const struct client_state *csp, const char *caller) if (!err) err = map(exports, "my-hostname", 1, html_encode(csp->my_hostname ? csp->my_hostname : "unknown"), 0); if (!err) err = map(exports, "homepage", 1, html_encode(HOME_PAGE_URL), 0); if (!err) err = map(exports, "default-cgi", 1, html_encode(CGI_PREFIX), 0); - if (!err) err = map(exports, "menu", 1, make_menu(caller), 0); + if (!err) err = map(exports, "menu", 1, make_menu(caller, csp->config->feature_flags), 0); if (!err) err = map(exports, "code-status", 1, CODE_STATUS, 1); if (!strncmpic(csp->config->usermanual, "file://", 7) || !strncmpic(csp->config->usermanual, "http", 4)) @@ -2481,14 +2491,18 @@ jb_err map_conditional(struct map *exports, const char *name, int choose_first) * * Description : Returns an HTML-formatted menu of the available * unhidden CGIs, excluding the one given in + * and the toggle CGI if toggling is disabled. * - * Parameters : self = name of CGI to leave out, can be NULL for + * Parameters : + * 1 : self = name of CGI to leave out, can be NULL for * complete listing. + * 2 : feature_flags = feature bitmap from csp->config + * * * Returns : menu string, or NULL on out-of-memory error. * *********************************************************************/ -char *make_menu(const char *self) +char *make_menu(const char *self, const unsigned feature_flags) { const struct cgi_dispatcher *d; char *result = strdup(""); @@ -2501,6 +2515,17 @@ char *make_menu(const char *self) /* List available unhidden CGI's and export as "other-cgis" */ for (d = cgi_dispatchers; d->name; d++) { + +#ifdef FEATURE_TOGGLE + if (!(feature_flags & RUNTIME_FEATURE_CGI_TOGGLE) && !strcmp(d->name, "toggle")) + { + /* + * Suppress the toggle link if remote toggling is disabled. + */ + continue; + } +#endif /* def FEATURE_TOGGLE */ + if (d->description && strcmp(d->name, self)) { string_append(&result, "