+ /*
+ * If it's an image-url, send back an image or redirect
+ * as specified by the relevant +image action
+ */
+#ifdef FEATURE_IMAGE_BLOCKING
+ if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
+ && is_imageurl(csp))
+ {
+ /* determine HOW images should be blocked */
+ p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
+
+ /* and handle accordingly: */
+ if ((p == NULL) || (0 == strcmpic(p, "logo")))
+ {
+ rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length);
+ if (rsp->body == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ rsp->content_length = image_junkbuster_gif_length;
+
+ if (enlist_unique_header(rsp->headers, "Content-Type", "image/gif"))
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ }
+
+ else if (0 == strcmpic(p, "blank"))
+ {
+ rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
+ if (rsp->body == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ rsp->content_length = image_blank_gif_length;
+
+ if (enlist_unique_header(rsp->headers, "Content-Type", "image/gif"))
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ }
+
+ else
+ {
+ rsp->status = strdup("302 Local Redirect from Junkbuster");
+ if (rsp->status == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+
+ if (enlist_unique_header(rsp->headers, "Location", p))
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ }
+ }
+ else
+#endif /* def FEATURE_IMAGE_BLOCKING */
+
+ /*
+ * Else, generate an HTML "blocked" message:
+ */
+ {
+ jb_err err;
+ struct map * exports;
+
+ /*
+ * Workaround for stupid Netscape bug which prevents
+ * pages from being displayed if loading a referenced
+ * JavaScript or style sheet fails. So make it appear
+ * as if it succeeded.
+ */
+ if ( NULL != (p = get_header_value(csp->headers, "User-Agent:"))
+ && !strncmpic(p, "mozilla", 7) /* Catch Netscape but */
+ && !strstr(p, "Gecko") /* save Mozilla, */
+ && !strstr(p, "compatible") /* MSIE */
+ && !strstr(p, "Opera")) /* and Opera. */
+ {
+ rsp->status = strdup("200 Request for blocked URL");
+ }
+ else
+ {
+ rsp->status = strdup("404 Request for blocked URL");
+ }
+
+ if (rsp->status == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+
+ exports = default_exports(csp, NULL);
+ if (exports == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+
+#ifdef FEATURE_FORCE_LOAD
+ err = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
+#else /* ifndef FEATURE_FORCE_LOAD */
+ err = map_block_killer(exports, "force-support");
+#endif /* ndef FEATURE_FORCE_LOAD */
+
+ if (!err) err = map(exports, "hostport", 1, html_encode(csp->http->hostport), 0);
+ if (!err) err = map(exports, "path", 1, html_encode(csp->http->path), 0);
+
+ if (err)
+ {
+ free_map(exports);
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+
+ err = template_fill_for_cgi(csp, "blocked", exports, rsp);
+ if (err)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ }
+
+ return finish_http_response(rsp);
+