2005-01-19 20:16:09 +03:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is SniffURI.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Erik van der Poel <erik@vanderpoel.org>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998-2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "all.h"
|
2000-02-01 21:24:20 +03:00
|
|
|
|
|
|
|
static char *me = NULL;
|
|
|
|
|
|
|
|
static char *passThese[] =
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
"HTTP_ACCEPT",
|
|
|
|
"HTTP_ACCEPT_CHARSET",
|
|
|
|
"HTTP_ACCEPT_LANGUAGE",
|
|
|
|
"HTTP_USER_AGENT",
|
|
|
|
|
|
|
|
/*
|
|
|
|
"HTTP_ACCEPT_ENCODING",
|
|
|
|
"HTTP_CONNECTION",
|
|
|
|
"HTTP_HOST",
|
|
|
|
"HTTP_KEEP_ALIVE",
|
|
|
|
"HTTP_REFERER",
|
|
|
|
*/
|
|
|
|
|
2000-02-01 21:24:20 +03:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTML(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTML(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTMLAttributeName(App *app, HTML *html, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTMLAttributeName(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTMLAttributeValue(App *app, HTML *html, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-21 21:14:10 +03:00
|
|
|
unsigned char *referer;
|
2005-01-19 20:16:09 +03:00
|
|
|
URL *url;
|
|
|
|
unsigned char *urlstring;
|
2005-01-21 00:09:40 +03:00
|
|
|
View *view;
|
2000-02-01 21:24:20 +03:00
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
view = &app->view;
|
2000-02-01 21:24:20 +03:00
|
|
|
|
|
|
|
if (html->currentAttributeIsURL)
|
|
|
|
{
|
|
|
|
url = urlRelative(html->base, html->currentAttribute->value);
|
2005-01-19 20:16:09 +03:00
|
|
|
urlstring = escapeHTML(url ? url->url : (unsigned char *) "");
|
2005-01-21 21:14:10 +03:00
|
|
|
fprintf(view->out, "<a href=\"%s%s", me, urlstring);
|
2003-01-02 20:07:34 +03:00
|
|
|
free(urlstring);
|
2005-01-21 21:14:10 +03:00
|
|
|
referer = escapeHTML(html->url);
|
|
|
|
fprintf(view->out, "&referer=%s\">", referer);
|
|
|
|
free(referer);
|
2000-02-01 21:24:20 +03:00
|
|
|
urlFree(url);
|
2005-02-05 19:30:04 +03:00
|
|
|
viewHTMLText(app, buf);
|
|
|
|
fprintf(view->out, "</a>");
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
2005-02-05 19:30:04 +03:00
|
|
|
else
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-02-05 19:30:04 +03:00
|
|
|
viewHTMLAttributeValue(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-03 04:06:24 +03:00
|
|
|
static void
|
|
|
|
cgiviewHTMLDeclaration(App *app, Buf *buf)
|
|
|
|
{
|
|
|
|
viewHTMLDeclaration(app, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cgiviewHTMLProcessingInstruction(App *app, Buf *buf)
|
|
|
|
{
|
|
|
|
viewHTMLProcessingInstruction(app, buf);
|
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTMLTag(App *app, HTML *html, Buf *buf)
|
|
|
|
{
|
|
|
|
viewHTMLTag(app, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cgiviewHTMLText(App *app, Buf *buf)
|
|
|
|
{
|
|
|
|
viewHTMLText(app, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cgiviewHTTPRequest(App *app, Buf *buf)
|
|
|
|
{
|
|
|
|
viewHTTP(app, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cgiviewHTTPRequestHeaderName(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTTPHeaderName(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTTPRequestHeaderValue(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTTPHeaderValue(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTTPResponse(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTTP(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTTPResponseBody(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTTP(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTTPResponseHeaderName(App *app, Buf *buf)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
viewHTTPHeaderName(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
static void
|
2005-01-25 11:22:29 +03:00
|
|
|
cgiviewHTTPResponseHeaderValue(App *app, Buf *buf, unsigned char *url)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-19 20:16:09 +03:00
|
|
|
unsigned char *urlstring;
|
2005-01-21 00:09:40 +03:00
|
|
|
View *view;
|
2000-02-01 21:24:20 +03:00
|
|
|
|
2005-01-21 00:09:40 +03:00
|
|
|
view = &app->view;
|
2000-02-01 21:24:20 +03:00
|
|
|
|
|
|
|
if (url)
|
|
|
|
{
|
2003-01-02 20:07:34 +03:00
|
|
|
urlstring = escapeHTML(url);
|
|
|
|
fprintf(view->out, "<a href=\"%s%s\">", me, urlstring);
|
|
|
|
free(urlstring);
|
2005-02-05 19:30:04 +03:00
|
|
|
viewHTTP(app, buf);
|
|
|
|
fprintf(view->out, "</a>");
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
2005-02-05 19:30:04 +03:00
|
|
|
else
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-02-05 19:30:04 +03:00
|
|
|
viewHTTPHeaderValue(app, buf);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-26 18:18:36 +04:00
|
|
|
static void
|
|
|
|
cgiviewPrintHTML(App *app, char *str)
|
|
|
|
{
|
|
|
|
viewPrintHTML(app, str);
|
|
|
|
}
|
|
|
|
|
2005-01-25 11:22:29 +03:00
|
|
|
static HTTPNameValue *
|
|
|
|
cgiviewGetEnv(App *app, char *referer, char *verbose, char **version)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
|
|
|
char **e;
|
|
|
|
extern char **environ;
|
2005-01-25 11:22:29 +03:00
|
|
|
char *equals;
|
2000-02-01 21:24:20 +03:00
|
|
|
int firstLetter;
|
|
|
|
char **h;
|
|
|
|
char *p;
|
|
|
|
char *q;
|
2005-01-25 11:22:29 +03:00
|
|
|
HTTPNameValue *r;
|
|
|
|
HTTPNameValue *ret;
|
2000-02-01 21:24:20 +03:00
|
|
|
char *scriptName;
|
|
|
|
|
2000-02-01 22:06:01 +03:00
|
|
|
scriptName = "view.cgi";
|
2005-01-25 11:22:29 +03:00
|
|
|
ret = malloc((NELEMS(passThese) + 1) * sizeof(HTTPNameValue));
|
2000-02-01 21:24:20 +03:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-02-01 22:06:01 +03:00
|
|
|
me = malloc(strlen(scriptName) + strlen(verbose) + 1);
|
2000-02-01 21:24:20 +03:00
|
|
|
if (!me)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-02-01 22:06:01 +03:00
|
|
|
strcpy(me, scriptName);
|
2000-02-01 21:24:20 +03:00
|
|
|
strcat(me, verbose);
|
|
|
|
|
|
|
|
e = environ;
|
|
|
|
r = ret;
|
2005-01-25 11:22:29 +03:00
|
|
|
viewReport(app, "will ignore these:");
|
2000-02-01 21:24:20 +03:00
|
|
|
while (*e)
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
equals = strchr(*e, '=');
|
|
|
|
if (!equals)
|
|
|
|
{
|
|
|
|
e++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*equals = 0;
|
2000-02-01 21:24:20 +03:00
|
|
|
h = passThese;
|
|
|
|
while (*h)
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
if (!strcmp(*e, *h))
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
if (*h)
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
r->name = malloc(strlen(*e) - 5 + 1);
|
|
|
|
if (!r->name)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
return NULL;
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
p = *e + 5;
|
2005-01-25 11:22:29 +03:00
|
|
|
q = (char *) r->name;
|
|
|
|
while (*p)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
|
|
|
firstLetter = 1;
|
|
|
|
while (*p && (*p != '=') && (*p != '_'))
|
|
|
|
{
|
|
|
|
if (firstLetter)
|
|
|
|
{
|
|
|
|
*q++ = *p++;
|
|
|
|
firstLetter = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*q++ = tolower(*p);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*p == '_')
|
|
|
|
{
|
|
|
|
*q++ = '-';
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
2005-01-25 11:22:29 +03:00
|
|
|
*q = 0;
|
|
|
|
r->value = (unsigned char *) strdup(equals + 1);
|
|
|
|
if (!r->value)
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
return NULL;
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
2005-01-25 11:22:29 +03:00
|
|
|
r++;
|
|
|
|
}
|
|
|
|
else if (!strncmp(*e, "HTTP_", 5))
|
|
|
|
{
|
|
|
|
viewReport(app, *e);
|
|
|
|
}
|
|
|
|
else if (!strcmp(*e, "SERVER_PROTOCOL"))
|
|
|
|
{
|
|
|
|
*version = strdup(equals + 1);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
e++;
|
|
|
|
}
|
2005-01-21 21:14:10 +03:00
|
|
|
if (referer)
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
r->name = (unsigned char *) strdup("Referer");
|
|
|
|
if (!r->name)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
r->value = (unsigned char *) strdup(referer);
|
|
|
|
if (!r->value)
|
2005-01-21 21:14:10 +03:00
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
return NULL;
|
2005-01-21 21:14:10 +03:00
|
|
|
}
|
2005-01-25 11:22:29 +03:00
|
|
|
r++;
|
2005-01-21 21:14:10 +03:00
|
|
|
}
|
2005-01-25 11:22:29 +03:00
|
|
|
r->name = NULL;
|
2005-01-21 00:09:40 +03:00
|
|
|
viewReportHTML(app, "<hr>");
|
2000-02-01 21:24:20 +03:00
|
|
|
|
2005-01-25 11:22:29 +03:00
|
|
|
return ret;
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char *ampersand;
|
2005-01-21 00:09:40 +03:00
|
|
|
App *app;
|
2000-02-01 21:24:20 +03:00
|
|
|
unsigned char *equals;
|
2005-01-25 19:04:39 +03:00
|
|
|
HTTPNameValue *h;
|
2005-01-25 11:22:29 +03:00
|
|
|
HTTPNameValue *headers;
|
2000-02-01 21:24:20 +03:00
|
|
|
char *name;
|
|
|
|
unsigned char *newURL;
|
|
|
|
char *p;
|
|
|
|
char *query;
|
2005-01-21 21:14:10 +03:00
|
|
|
unsigned char *referer;
|
2000-02-01 21:24:20 +03:00
|
|
|
URL *u;
|
|
|
|
unsigned char *url;
|
|
|
|
char *verbose;
|
2005-01-25 11:22:29 +03:00
|
|
|
char *version;
|
2000-02-01 21:24:20 +03:00
|
|
|
View *view;
|
|
|
|
|
2005-01-19 20:16:09 +03:00
|
|
|
if (!netInit())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!threadInit())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2000-02-01 21:24:20 +03:00
|
|
|
|
2005-01-21 21:14:10 +03:00
|
|
|
referer = NULL;
|
2000-02-01 21:24:20 +03:00
|
|
|
url = NULL;
|
|
|
|
|
|
|
|
verbose = "?url=";
|
|
|
|
|
|
|
|
query = getenv("QUERY_STRING");
|
2005-01-21 00:09:40 +03:00
|
|
|
app = appAlloc();
|
|
|
|
app->html = cgiviewHTML;
|
|
|
|
app->htmlAttributeName = cgiviewHTMLAttributeName;
|
|
|
|
app->htmlAttributeValue = cgiviewHTMLAttributeValue;
|
2005-02-03 04:06:24 +03:00
|
|
|
app->htmlDeclaration = cgiviewHTMLDeclaration;
|
|
|
|
app->htmlProcessingInstruction = cgiviewHTMLProcessingInstruction;
|
2005-01-21 00:09:40 +03:00
|
|
|
app->htmlTag = cgiviewHTMLTag;
|
|
|
|
app->htmlText = cgiviewHTMLText;
|
2005-01-25 11:22:29 +03:00
|
|
|
app->httpRequest = cgiviewHTTPRequest;
|
|
|
|
app->httpRequestHeaderName = cgiviewHTTPRequestHeaderName;
|
|
|
|
app->httpRequestHeaderValue = cgiviewHTTPRequestHeaderValue;
|
|
|
|
app->httpResponse = cgiviewHTTPResponse;
|
|
|
|
app->httpResponseBody = cgiviewHTTPResponseBody;
|
|
|
|
app->httpResponseHeaderName = cgiviewHTTPResponseHeaderName;
|
|
|
|
app->httpResponseHeaderValue = cgiviewHTTPResponseHeaderValue;
|
2005-07-26 18:18:36 +04:00
|
|
|
app->printHTML = cgiviewPrintHTML;
|
2005-01-21 00:09:40 +03:00
|
|
|
view = &app->view;
|
2000-02-01 21:24:20 +03:00
|
|
|
view->out = stdout;
|
|
|
|
freopen("/dev/null", "w", stderr);
|
|
|
|
fprintf(view->out, "Content-Type: text/html\n");
|
|
|
|
fprintf(view->out, "\n");
|
|
|
|
if (query)
|
|
|
|
{
|
|
|
|
p = query;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
name = p;
|
|
|
|
ampersand = strchr(p, '&');
|
|
|
|
if (ampersand)
|
|
|
|
{
|
|
|
|
*ampersand = 0;
|
|
|
|
p = ampersand + 1;
|
|
|
|
}
|
|
|
|
equals = (unsigned char *) strchr(name, '=');
|
|
|
|
if (equals)
|
|
|
|
{
|
|
|
|
*equals = 0;
|
2005-01-21 21:14:10 +03:00
|
|
|
if (!strcmp(name, "referer"))
|
|
|
|
{
|
|
|
|
referer = equals + 1;
|
|
|
|
urlDecode(referer);
|
|
|
|
}
|
|
|
|
else if (!strcmp(name, "url"))
|
2000-02-01 21:24:20 +03:00
|
|
|
{
|
|
|
|
url = equals + 1;
|
|
|
|
urlDecode(url);
|
|
|
|
}
|
|
|
|
else if (!strcmp(name, "verbose"))
|
|
|
|
{
|
|
|
|
verbose = "?verbose=on&url=";
|
|
|
|
viewVerbose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (ampersand);
|
|
|
|
}
|
|
|
|
else if (argc > 1)
|
|
|
|
{
|
|
|
|
url = (unsigned char *) argv[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(view->out, "no environment variable QUERY_STRING<br>\n");
|
|
|
|
fprintf(view->out, "and no arg passed<br>\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (url && (*url))
|
|
|
|
{
|
2005-02-05 19:30:04 +03:00
|
|
|
fprintf(view->out, "<html><head><title>View %s</title>", url);
|
|
|
|
fprintf(view->out, "<link rel=stylesheet href=view.css>");
|
|
|
|
fprintf(view->out, "</head><body>\n");
|
2005-01-21 00:09:40 +03:00
|
|
|
viewReport(app, "input url:");
|
|
|
|
viewReport(app, (char *) url);
|
|
|
|
viewReportHTML(app, "<hr>");
|
2000-02-01 21:24:20 +03:00
|
|
|
u = urlParse(url);
|
|
|
|
if
|
|
|
|
(
|
|
|
|
((!u->scheme)||(!strcmp((char *) u->scheme, "http"))) &&
|
|
|
|
(!u->host) &&
|
|
|
|
(*url != '/')
|
|
|
|
)
|
|
|
|
{
|
|
|
|
newURL = calloc(strlen((char *) url) + 3, 1);
|
|
|
|
if (!newURL)
|
|
|
|
{
|
2005-01-21 00:09:40 +03:00
|
|
|
viewReport(app, "calloc failed");
|
2000-02-01 21:24:20 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
strcpy((char *) newURL, "//");
|
|
|
|
strcat((char *) newURL, (char *) url);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newURL = copyString(url);
|
|
|
|
}
|
|
|
|
urlFree(u);
|
|
|
|
u = urlParse(newURL);
|
|
|
|
if
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(!u->scheme) ||
|
|
|
|
(!strcmp((char *) u->scheme, "http"))
|
|
|
|
) &&
|
|
|
|
(!*u->path)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
url = newURL;
|
|
|
|
newURL = calloc(strlen((char *) url) + 2, 1);
|
|
|
|
if (!newURL)
|
|
|
|
{
|
2005-01-21 00:09:40 +03:00
|
|
|
viewReport(app, "calloc failed");
|
2000-02-01 21:24:20 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
strcpy((char *) newURL, (char *) url);
|
|
|
|
free(url);
|
|
|
|
strcat((char *) newURL, "/");
|
|
|
|
}
|
|
|
|
urlFree(u);
|
|
|
|
u = urlRelative(
|
|
|
|
(unsigned char *) "http://www.mozilla.org/index.html",
|
|
|
|
newURL);
|
|
|
|
free(newURL);
|
2005-01-21 00:09:40 +03:00
|
|
|
viewReport(app, "fully qualified url:");
|
|
|
|
viewReport(app, (char *) u->url);
|
|
|
|
viewReportHTML(app, "<hr>");
|
2000-02-01 21:24:20 +03:00
|
|
|
if (!strcmp((char *) u->scheme, "http"))
|
|
|
|
{
|
2005-01-25 11:22:29 +03:00
|
|
|
version = NULL;
|
|
|
|
headers = cgiviewGetEnv(app, (char *) referer,
|
|
|
|
verbose, &version);
|
|
|
|
if (!headers)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
httpFree(httpProcess(app, u, version, headers));
|
2005-01-25 19:04:39 +03:00
|
|
|
h = headers;
|
|
|
|
while (h->name)
|
|
|
|
{
|
|
|
|
free(h->name);
|
|
|
|
free(h->value);
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
free(headers);
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf
|
|
|
|
(
|
|
|
|
view->out,
|
|
|
|
"Sorry, %s URLs are not supported yet. "
|
|
|
|
"Only http URLs are supported.",
|
|
|
|
u->scheme
|
|
|
|
);
|
|
|
|
}
|
2005-02-04 23:11:34 +03:00
|
|
|
fprintf(view->out, "</body></html>\n");
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-20 04:38:31 +03:00
|
|
|
fprintf(view->out, "<html><head><title>SniffURI Error</title>");
|
|
|
|
fprintf(view->out, "</head><body><h2>Please enter a URI</h2>");
|
|
|
|
fprintf(view->out, "<a href=index.html>Go Back</a>");
|
|
|
|
fprintf(view->out, "</body></html>");
|
2000-02-01 21:24:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
return 1;
|
|
|
|
}
|