r3160 jmb - /trunk/netsurf/desktop/netsurf.c
by netsurf@semichrome.net
Author: jmb
Date: Wed Jan 31 00:02:38 2007
New Revision: 3160
URL: http://svn.semichrome.net?rev=3160&view=rev
Log:
Revert r3156 (content cleaner frequency reduction) as it introduces
potential stability issues.
Modified:
trunk/netsurf/desktop/netsurf.c
Modified: trunk/netsurf/desktop/netsurf.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/netsurf.c?rev=3160&r1=315...
==============================================================================
--- trunk/netsurf/desktop/netsurf.c (original)
+++ trunk/netsurf/desktop/netsurf.c Wed Jan 31 00:02:38 2007
@@ -33,9 +33,7 @@
static void netsurf_poll(void);
static void netsurf_exit(void);
static void lib_init(void);
-static void content_clean_wrapper(void *p);
-#define CONTENT_CLEAN_FREQ (500) /* cs */
/**
* Gui NetSurf main().
@@ -85,8 +83,6 @@
fetch_init();
fetchcache_init();
gui_init2(argc, argv);
-
- schedule(CONTENT_CLEAN_FREQ, content_clean_wrapper, NULL);
}
/**
@@ -95,6 +91,7 @@
void netsurf_poll(void)
{
+ content_clean();
gui_poll(fetch_active);
fetch_poll();
}
@@ -106,8 +103,6 @@
void netsurf_exit(void)
{
- schedule_remove(content_clean_wrapper, NULL);
-
LOG(("Closing GUI"));
gui_quit();
LOG(("Closing content"));
@@ -135,12 +130,3 @@
}
-/**
- * Wrapper for content cleaner callback
- */
-static void content_clean_wrapper(void *p)
-{
- content_clean();
-
- schedule(CONTENT_CLEAN_FREQ, content_clean_wrapper, NULL);
-}
16 years, 8 months
r3159 jmb - in /trunk/netsurf: content/fetch.c render/form.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Jan 30 23:19:21 2007
New Revision: 3159
URL: http://svn.semichrome.net?rev=3159&view=rev
Log:
Bring handling of submission of blank file inputs in line with other browsers.
Tidy up fetch_post_convert while I'm at it.
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/render/form.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3159&r1=3158&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Tue Jan 30 23:19:21 2007
@@ -213,7 +213,7 @@
{
CURLcode code;
char *ua = make_useragent();
-
+
if (ua != NULL)
user_agent = ua;
@@ -1354,17 +1354,15 @@
struct curl_httppost *fetch_post_convert(struct form_successful_control *control)
{
struct curl_httppost *post = 0, *last = 0;
- char *mimetype = 0;
- char *leafname = 0;
-#ifdef riscos
- char *temp;
- int leaflen;
-#endif
+ CURLFORMcode code;
for (; control; control = control->next) {
if (control->file) {
- mimetype = fetch_mimetype(control->value);
+ char *leafname = 0;
#ifdef riscos
+ char *temp;
+ int leaflen;
+
temp = strrchr(control->value, '.');
if (!temp)
temp = control->value; /* already leafname */
@@ -1376,7 +1374,6 @@
leafname = malloc(leaflen + 1);
if (!leafname) {
LOG(("malloc failed"));
- free(mimetype);
continue;
}
memcpy(leafname, temp, leaflen + 1);
@@ -1392,23 +1389,58 @@
else
leafname += 1;
#endif
- curl_formadd(&post, &last,
+ /* We have to special case filenames of "", so curl
+ * a) actually attempts the fetch and
+ * b) doesn't attempt to open the file ""
+ */
+ if (control->value[0] == '\0') {
+ /* dummy buffer - needs to be static so
+ * pointer's still valid when we go out
+ * of scope (not that libcurl should be
+ * attempting to access it, of course). */
+ static char buf;
+
+ code = curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_BUFFER, control->value,
+ /* needed, as basename("") == "." */
+ CURLFORM_FILENAME, "",
+ CURLFORM_BUFFERPTR, &buf,
+ CURLFORM_BUFFERLENGTH, 0,
+ CURLFORM_CONTENTTYPE,
+ "application/octet-stream",
+ CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ LOG(("curl_formadd: %d (%s)",
+ code, control->name));
+ } else {
+ char *mimetype = fetch_mimetype(control->value);
+ code = curl_formadd(&post, &last,
CURLFORM_COPYNAME, control->name,
CURLFORM_FILE, control->value,
CURLFORM_FILENAME, leafname,
CURLFORM_CONTENTTYPE,
(mimetype != 0 ? mimetype : "text/plain"),
CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ LOG(("curl_formadd: %d (%s=%s)",
+ code, control->name,
+ control->value));
+ free(mimetype);
+ }
#ifdef riscos
free(leafname);
#endif
- free(mimetype);
}
else {
- curl_formadd(&post, &last,
+ code = curl_formadd(&post, &last,
CURLFORM_COPYNAME, control->name,
CURLFORM_COPYCONTENTS, control->value,
CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ LOG(("curl_formadd: %d (%s=%s)", code,
+ control->name,
+ control->value));
}
}
Modified: trunk/netsurf/render/form.c
URL: http://svn.semichrome.net/trunk/netsurf/render/form.c?rev=3159&r1=3158&r2...
==============================================================================
--- trunk/netsurf/render/form.c (original)
+++ trunk/netsurf/render/form.c Tue Jan 30 23:19:21 2007
@@ -38,8 +38,8 @@
* \return a new structure, or 0 on memory exhaustion
*/
-struct form *form_new(char *action, char *target, form_method method, char *charset,
- char *doc_charset)
+struct form *form_new(char *action, char *target, form_method method,
+ char *charset, char *doc_charset)
{
struct form *form;
@@ -387,8 +387,14 @@
case GADGET_FILE:
/* file */
- if (!control->value)
- continue;
+ /* Handling of blank file entries is
+ * implementation defined - we're perfectly
+ * within our rights to treat it as an
+ * unsuccessful control. Unfortunately, every
+ * other browser submits the field with
+ * a blank filename and no content. So,
+ * that's what we have to do, too.
+ */
success_new = malloc(sizeof(*success_new));
if (!success_new) {
LOG(("malloc failed"));
@@ -396,7 +402,8 @@
}
success_new->file = true;
success_new->name = strdup(control->name);
- success_new->value = strdup(control->value);
+ success_new->value = strdup(control->value ?
+ control->value : "");
success_new->next = 0;
last_success->next = success_new;
last_success = success_new;
16 years, 8 months
r3158 rjek - in /trunk/netsurf: content/fetch.c desktop/netsurf.h desktop/version.c utils/utils.c utils/utils.h
by netsurf@semichrome.net
Author: rjek
Date: Tue Jan 30 19:51:54 2007
New Revision: 3158
URL: http://svn.semichrome.net?rev=3158&view=rev
Log:
Generates and use a User-Agent: string based on new netsurf_version_major/minor values, and results of uname().
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/desktop/netsurf.h
trunk/netsurf/desktop/version.c
trunk/netsurf/utils/utils.c
trunk/netsurf/utils/utils.h
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3158&r1=3157&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Tue Jan 30 19:51:54 2007
@@ -98,7 +98,7 @@
struct cache_handle *r_next; /**< Next cached handle in ring. */
};
-static const char * const user_agent = "NetSurf";
+static char *user_agent = "NetSurf";
CURLM *fetch_curl_multi; /**< Global cURL multi handle. */
/** Curl handle with default options set; not used for transfers. */
static CURL *fetch_blank_curl;
@@ -212,6 +212,10 @@
void fetch_init(void)
{
CURLcode code;
+ char *ua = make_useragent();
+
+ if (ua != NULL)
+ user_agent = ua;
code = curl_global_init(CURL_GLOBAL_ALL);
if (code != CURLE_OK)
Modified: trunk/netsurf/desktop/netsurf.h
URL: http://svn.semichrome.net/trunk/netsurf/desktop/netsurf.h?rev=3158&r1=315...
==============================================================================
--- trunk/netsurf/desktop/netsurf.h (original)
+++ trunk/netsurf/desktop/netsurf.h Tue Jan 30 19:51:54 2007
@@ -12,6 +12,8 @@
extern bool netsurf_quit;
extern const char * const netsurf_version;
+extern const int netsurf_version_major;
+extern const int netsurf_version_minor;
#endif
Modified: trunk/netsurf/desktop/version.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/version.c?rev=3158&r1=315...
==============================================================================
--- trunk/netsurf/desktop/version.c (original)
+++ trunk/netsurf/desktop/version.c Tue Jan 30 19:51:54 2007
@@ -1,2 +1,3 @@
const char * const netsurf_version = "Development Build";
-
+const int netsurf_version_major = 0;
+const int netsurf_version_minor = 0;
Modified: trunk/netsurf/utils/utils.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.c?rev=3158&r1=3157&r2...
==============================================================================
--- trunk/netsurf/utils/utils.c (original)
+++ trunk/netsurf/utils/utils.c Tue Jan 30 19:51:54 2007
@@ -2,6 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
+ * Copyright 2007 Rob Kendrick <rjek(a)netsurf-browser.org>
* Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202(a)ecs.soton.ac.uk>
@@ -15,6 +16,8 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/utsname.h>
+#include <sys/time.h>
#include <regex.h>
#include <time.h>
#include "netsurf/utils/config.h"
@@ -23,6 +26,7 @@
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utf8.h"
#include "netsurf/utils/utils.h"
+#include "netsurf/desktop/netsurf.h"
char * strip(char * const s)
@@ -254,6 +258,37 @@
return ((tv.tv_sec * 100) + (tv.tv_usec / 10000));
}
+/** Generate a string suitable for use as a user agent in HTTP requests.
+ *
+ * \return heap-allocated result string, or NULL if the allocation failed.
+ */
+#define UA_BUF_SIZE 128
+char *make_useragent(void)
+{
+ struct utsname un;
+ char ua_name[UA_BUF_SIZE];
+ char ua_machine[UA_BUF_SIZE];
+ char *r;
+
+ snprintf(ua_name, UA_BUF_SIZE, "NetSurf/%d.%d",
+ netsurf_version_major,
+ netsurf_version_minor);
+
+ if (uname(&un) != 0) {
+ strncpy(ua_machine, "unknown machine", UA_BUF_SIZE);
+ } else {
+ snprintf(ua_machine, UA_BUF_SIZE, "(%s; %s)", un.sysname,
+ un.machine);
+ }
+
+ if ((r = malloc(strlen(ua_name) + strlen(ua_machine) + 2)) == NULL)
+ return NULL;
+
+ sprintf(r, "%s %s", ua_name, ua_machine);
+
+ return r;
+}
+
#ifdef __FreeBSD__
/**
Modified: trunk/netsurf/utils/utils.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.h?rev=3158&r1=3157&r2...
==============================================================================
--- trunk/netsurf/utils/utils.h (original)
+++ trunk/netsurf/utils/utils.h Tue Jan 30 19:51:54 2007
@@ -57,6 +57,7 @@
const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
unsigned int wallclock(void);
+char *make_useragent(void);
#ifdef __FreeBSD__
/* FreeBSD lacks strndup */
char *strndup(const char *s, size_t n);
16 years, 8 months
r3157 rjek - in /trunk/netsurf: content/content.c content/content.h utils/utils.c utils/utils.h
by netsurf@semichrome.net
Author: rjek
Date: Tue Jan 30 15:32:31 2007
New Revision: 3157
URL: http://svn.semichrome.net?rev=3157&view=rev
Log:
Make time taken that is displayed in status bar use gettimeofday()-based time rather than clock()-based time
Modified:
trunk/netsurf/content/content.c
trunk/netsurf/content/content.h
trunk/netsurf/utils/utils.c
trunk/netsurf/utils/utils.h
Modified: trunk/netsurf/content/content.c
URL: http://svn.semichrome.net/trunk/netsurf/content/content.c?rev=3157&r1=315...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Tue Jan 30 15:32:31 2007
@@ -376,7 +376,7 @@
c->refresh = 0;
c->bitmap = 0;
c->fresh = false;
- c->time = clock();
+ c->time = wallclock();
c->size = 0;
c->title = 0;
c->active = 0;
@@ -614,7 +614,7 @@
{
char token[20];
const char *status;
- clock_t time;
+ unsigned int time;
snprintf(token, sizeof token, "HTTP%li", c->http_code);
status = messages_get(token);
@@ -624,13 +624,13 @@
if (c->status == CONTENT_STATUS_TYPE_UNKNOWN ||
c->status == CONTENT_STATUS_LOADING ||
c->status == CONTENT_STATUS_READY)
- time = clock() - c->time;
+ time = wallclock() - c->time;
else
time = c->time;
snprintf(c->status_message, sizeof (c->status_message),
"%s (%.1fs) %s", status,
- (float) time / CLOCKS_PER_SEC, c->sub_status);
+ (float) time / 100, c->sub_status);
/* LOG(("%s", c->status_message)); */
}
@@ -752,7 +752,7 @@
union content_msg_data msg_data;
c->status = CONTENT_STATUS_DONE;
- c->time = clock() - c->time;
+ c->time = wallclock() - c->time;
content_update_status(c);
content_broadcast(c, CONTENT_MSG_DONE, msg_data);
}
Modified: trunk/netsurf/content/content.h
URL: http://svn.semichrome.net/trunk/netsurf/content/content.h?rev=3157&r1=315...
==============================================================================
--- trunk/netsurf/content/content.h (original)
+++ trunk/netsurf/content/content.h Tue Jan 30 15:32:31 2007
@@ -16,7 +16,6 @@
#define _NETSURF_DESKTOP_CONTENT_H_
#include <stdint.h>
-#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content_type.h"
#include "netsurf/css/css.h"
@@ -179,7 +178,7 @@
* shared between users. */
bool fresh;
struct cache_data *cache_data; /**< Cache control data */
- clock_t time; /**< Creation time, if TYPE_UNKNOWN,
+ unsigned int time; /**< Creation time, if TYPE_UNKNOWN,
LOADING or READY,
otherwise total time. */
Modified: trunk/netsurf/utils/utils.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.c?rev=3157&r1=3156&r2...
==============================================================================
--- trunk/netsurf/utils/utils.c (original)
+++ trunk/netsurf/utils/utils.c Tue Jan 30 15:32:31 2007
@@ -236,6 +236,23 @@
return NULL;
}
+/**
+ * Returns a number of centiseconds, that increases in real time, for the
+ * purposes of measuring how long something takes in wall-clock terms. It uses
+ * gettimeofday() for this. Should the call to gettimeofday() fail, it returns
+ * zero.
+ *
+ * \return number of centiseconds that increases monotonically
+ */
+unsigned int wallclock(void)
+{
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) == -1)
+ return 0;
+
+ return ((tv.tv_sec * 100) + (tv.tv_usec / 10000));
+}
#ifdef __FreeBSD__
Modified: trunk/netsurf/utils/utils.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.h?rev=3157&r1=3156&r2...
==============================================================================
--- trunk/netsurf/utils/utils.h (original)
+++ trunk/netsurf/utils/utils.h Tue Jan 30 15:32:31 2007
@@ -56,6 +56,7 @@
char *human_friendly_bytesize(unsigned long bytesize);
const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
+unsigned int wallclock(void);
#ifdef __FreeBSD__
/* FreeBSD lacks strndup */
char *strndup(const char *s, size_t n);
16 years, 8 months
r3156 jmb - /trunk/netsurf/desktop/netsurf.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Jan 30 00:44:53 2007
New Revision: 3156
URL: http://svn.semichrome.net?rev=3156&view=rev
Log:
Attempt to perform content cleaning far less frequently.
Modified:
trunk/netsurf/desktop/netsurf.c
Modified: trunk/netsurf/desktop/netsurf.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/netsurf.c?rev=3156&r1=315...
==============================================================================
--- trunk/netsurf/desktop/netsurf.c (original)
+++ trunk/netsurf/desktop/netsurf.c Tue Jan 30 00:44:53 2007
@@ -33,7 +33,9 @@
static void netsurf_poll(void);
static void netsurf_exit(void);
static void lib_init(void);
+static void content_clean_wrapper(void *p);
+#define CONTENT_CLEAN_FREQ (500) /* cs */
/**
* Gui NetSurf main().
@@ -83,6 +85,8 @@
fetch_init();
fetchcache_init();
gui_init2(argc, argv);
+
+ schedule(CONTENT_CLEAN_FREQ, content_clean_wrapper, NULL);
}
/**
@@ -91,7 +95,6 @@
void netsurf_poll(void)
{
- content_clean();
gui_poll(fetch_active);
fetch_poll();
}
@@ -103,6 +106,8 @@
void netsurf_exit(void)
{
+ schedule_remove(content_clean_wrapper, NULL);
+
LOG(("Closing GUI"));
gui_quit();
LOG(("Closing content"));
@@ -130,3 +135,12 @@
}
+/**
+ * Wrapper for content cleaner callback
+ */
+static void content_clean_wrapper(void *p)
+{
+ content_clean();
+
+ schedule(CONTENT_CLEAN_FREQ, content_clean_wrapper, NULL);
+}
16 years, 8 months
r3155 rjek - /trunk/netsurf/makefile
by netsurf@semichrome.net
Author: rjek
Date: Mon Jan 29 23:09:40 2007
New Revision: 3155
URL: http://svn.semichrome.net?rev=3155&view=rev
Log:
Change -std=c9x to -std=c99
Modified:
trunk/netsurf/makefile
Modified: trunk/netsurf/makefile
URL: http://svn.semichrome.net/trunk/netsurf/makefile?rev=3155&r1=3154&r2=3155...
==============================================================================
--- trunk/netsurf/makefile (original)
+++ trunk/netsurf/makefile Mon Jan 29 23:09:40 2007
@@ -122,14 +122,14 @@
# CFLAGS have to appear after the inclusion of platform specific files as the
# PLATFORM_CFLAGS variables are defined in them
-CFLAGS_RISCOS = -std=c9x -D_BSD_SOURCE -D_POSIX_C_SOURCE -Driscos -DBOOL_DEFINED -O \
+CFLAGS_RISCOS = -std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE -Driscos -DBOOL_DEFINED -O \
$(WARNFLAGS) -I.. $(PLATFORM_CFLAGS_RISCOS) -mpoke-function-name \
# -include netsurf/utils/memdebug.h
CFLAGS_RISCOS_SMALL = $(CFLAGS_RISCOS) -Dsmall
CFLAGS_NCOS = $(CFLAGS_RISCOS) -Dncos
-CFLAGS_DEBUG = -std=c9x -D_BSD_SOURCE -DDEBUG_BUILD $(WARNFLAGS) -I.. \
+CFLAGS_DEBUG = -std=c99 -D_BSD_SOURCE -DDEBUG_BUILD $(WARNFLAGS) -I.. \
$(PLATFORM_CFLAGS_DEBUG) -g
-CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -Dgtk \
+CFLAGS_GTK = -Dnsgtk -std=c99 -D_BSD_SOURCE -Dgtk \
$(WARNFLAGS) -I.. -g -O0 -Wformat=2 -DNDEBUG \
`pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags`
16 years, 8 months
r3154 bursa - in /trunk/netsurf: ./ content/ css/ desktop/ gtk/ render/ utils/
by netsurf@semichrome.net
Author: bursa
Date: Mon Jan 29 22:27:15 2007
New Revision: 3154
URL: http://svn.semichrome.net?rev=3154&view=rev
Log:
Make GTK build compile on FreeBSD.
Modified:
trunk/netsurf/content/content.c
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/content/fetchcache.c
trunk/netsurf/content/urldb.c
trunk/netsurf/css/makeenum
trunk/netsurf/css/parser.y
trunk/netsurf/css/ruleset.c
trunk/netsurf/desktop/browser.c
trunk/netsurf/gtk/gtk_gui.c
trunk/netsurf/makefile
trunk/netsurf/posix.mk
trunk/netsurf/render/box_construct.c
trunk/netsurf/render/directory.c
trunk/netsurf/utils/filename.c
trunk/netsurf/utils/talloc.h
trunk/netsurf/utils/utils.c
trunk/netsurf/utils/utils.h
Modified: trunk/netsurf/content/content.c
URL: http://svn.semichrome.net/trunk/netsurf/content/content.c?rev=3154&r1=315...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Mon Jan 29 22:27:15 2007
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3154&r1=3153&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Mon Jan 29 22:27:15 2007
@@ -24,14 +24,15 @@
#include <string.h>
#include <strings.h>
#include <time.h>
+#include <sys/select.h>
#include <sys/stat.h>
#ifdef riscos
#include <unixlib/local.h>
#endif
-#include "curl/curl.h"
+#include <curl/curl.h>
#include "netsurf/utils/config.h"
#ifdef WITH_SSL
-#include "openssl/ssl.h"
+#include <openssl/ssl.h>
#endif
#include "netsurf/content/fetch.h"
#include "netsurf/content/urldb.h"
Modified: trunk/netsurf/content/fetch.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.h?rev=3154&r1=3153&...
==============================================================================
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Mon Jan 29 22:27:15 2007
@@ -13,7 +13,8 @@
#define _NETSURF_DESKTOP_FETCH_H_
#include <stdbool.h>
-#include "curl/curl.h"
+#include <sys/select.h>
+#include <curl/curl.h>
#include "netsurf/utils/config.h"
typedef enum {
Modified: trunk/netsurf/content/fetchcache.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchcache.c?rev=3154&r1=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Mon Jan 29 22:27:15 2007
@@ -16,6 +16,7 @@
#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <string.h>
+#include <strings.h>
#include <sys/types.h>
#include <regex.h>
#include <time.h>
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=3154&r1=3153&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Mon Jan 29 22:27:15 2007
@@ -76,8 +76,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <time.h>
+#include <sys/select.h>
#include <curl/curl.h>
#include "netsurf/image/bitmap.h"
Modified: trunk/netsurf/css/makeenum
URL: http://svn.semichrome.net/trunk/netsurf/css/makeenum?rev=3154&r1=3153&r2=...
==============================================================================
--- trunk/netsurf/css/makeenum (original)
+++ trunk/netsurf/css/makeenum Mon Jan 29 22:27:15 2007
@@ -11,7 +11,7 @@
open H, ">$out.h" or die "open 'enum.h' failed";
open C, ">$out.c" or die "open 'enum.c' failed";
-print C "#include <string.h>\n";
+print C "#include <strings.h>\n";
print C "#include \"$out.h\"\n\n";
while (<>) {
Modified: trunk/netsurf/css/parser.y
URL: http://svn.semichrome.net/trunk/netsurf/css/parser.y?rev=3154&r1=3153&r2=...
==============================================================================
--- trunk/netsurf/css/parser.y (original)
+++ trunk/netsurf/css/parser.y Mon Jan 29 22:27:15 2007
@@ -398,7 +398,7 @@
%extra_argument { struct css_parser_params *param }
%include {
-#include <string.h>
+#include <strings.h>
#define CSS_INTERNALS
#include "netsurf/css/css.h"
#include "netsurf/utils/utils.h" }
Modified: trunk/netsurf/css/ruleset.c
URL: http://svn.semichrome.net/trunk/netsurf/css/ruleset.c?rev=3154&r1=3153&r2...
==============================================================================
--- trunk/netsurf/css/ruleset.c (original)
+++ trunk/netsurf/css/ruleset.c Mon Jan 29 22:27:15 2007
@@ -23,6 +23,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#define CSS_INTERNALS
#define NDEBUG
#include "netsurf/css/css.h"
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=3154&r1=315...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Mon Jan 29 22:27:15 2007
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/select.h>
#include "curl/curl.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/fetch.h"
Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.c?rev=3154&r1=3153&r2...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Mon Jan 29 22:27:15 2007
@@ -13,6 +13,7 @@
#include <string.h>
#include <unistd.h>
#include <limits.h>
+#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <curl/curl.h>
Modified: trunk/netsurf/makefile
URL: http://svn.semichrome.net/trunk/netsurf/makefile?rev=3154&r1=3153&r2=3154...
==============================================================================
--- trunk/netsurf/makefile (original)
+++ trunk/netsurf/makefile Mon Jan 29 22:27:15 2007
@@ -94,7 +94,7 @@
OBJS_DEBUGRO=$(OBJECTS_DEBUGRO:%.o=$(OBJDIR_RISCOS)/%.o)
-OBJDIR_GTK = $(shell $(SYSTEM_CC) -dumpmachine)-gtk
+OBJDIR_GTK = objects-gtk
SOURCES_GTK=$(OBJECTS_GTK:.o=.c)
OBJS_GTK=$(OBJECTS_GTK:%.o=$(OBJDIR_GTK)/%.o)
@@ -129,7 +129,7 @@
CFLAGS_NCOS = $(CFLAGS_RISCOS) -Dncos
CFLAGS_DEBUG = -std=c9x -D_BSD_SOURCE -DDEBUG_BUILD $(WARNFLAGS) -I.. \
$(PLATFORM_CFLAGS_DEBUG) -g
-CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -D_POSIX_C_SOURCE -Dgtk \
+CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -Dgtk \
$(WARNFLAGS) -I.. -g -O0 -Wformat=2 -DNDEBUG \
`pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags`
Modified: trunk/netsurf/posix.mk
URL: http://svn.semichrome.net/trunk/netsurf/posix.mk?rev=3154&r1=3153&r2=3154...
==============================================================================
--- trunk/netsurf/posix.mk (original)
+++ trunk/netsurf/posix.mk Mon Jan 29 22:27:15 2007
@@ -10,14 +10,14 @@
-I$(GCCSDK_INSTALL_ENV)/include/libmng \
#-finstrument-functions
PLATFORM_CFLAGS_DEBUG = -I/usr/include/libxml2 -I/riscos/src/OSLib \
- -I/riscos/include/libjpeg -D_POSIX_C_SOURCE
+ -I/riscos/include/libjpeg -D_POSIX_C_SOURCE=200112
PLATFORM_AFLAGS_RISCOS = -I$(GCCSDK_INSTALL_ENV)/include
LDFLAGS_RISCOS = -L$(GCCSDK_INSTALL_ENV)/lib -lxml2 -lz -lcurl -lssl -lcrypto \
-lcares -lmng -lOSLib32 -ljpeg -lrufl -lpencil #-lprof
LDFLAGS_SMALL = -L$(GCCSDK_INSTALL_ENV)/lib -lxml2 -lz -lucurl \
-lcares -lmng -lOSLib32 -ljpeg -lrufl -lpencil
-LDFLAGS_DEBUG = -L/usr/lib -lxml2 -lz -lm -lcurl -lssl -lcrypto -ldl -lmng \
+LDFLAGS_DEBUG = -L/usr/lib -lxml2 -lz -lm -lcurl -lssl -lcrypto -lmng \
-ljpeg -llcms
# Hackery for Cygwin - it has no libdl, so remove it from LDFLAGS
Modified: trunk/netsurf/render/box_construct.c
URL: http://svn.semichrome.net/trunk/netsurf/render/box_construct.c?rev=3154&r...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Jan 29 22:27:15 2007
@@ -19,6 +19,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include "libxml/HTMLparser.h"
#include "libxml/parserInternals.h"
#include "netsurf/utils/config.h"
Modified: trunk/netsurf/render/directory.c
URL: http://svn.semichrome.net/trunk/netsurf/render/directory.c?rev=3154&r1=31...
==============================================================================
--- trunk/netsurf/render/directory.c (original)
+++ trunk/netsurf/render/directory.c Mon Jan 29 22:27:15 2007
@@ -101,8 +101,8 @@
return false;
}
while ((entry = readdir(parent)) != NULL) {
- if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) ||
- (!strcmp(entry->d_name, "..")))
+ if (!strcmp(entry->d_name, ".") ||
+ !strcmp(entry->d_name, ".."))
continue;
snprintf(buffer, sizeof(buffer), "<a href=\"%s/%s\">%s</a>\n",
Modified: trunk/netsurf/utils/filename.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/filename.c?rev=3154&r1=3153...
==============================================================================
--- trunk/netsurf/utils/filename.c (original)
+++ trunk/netsurf/utils/filename.c Mon Jan 29 22:27:15 2007
@@ -216,8 +216,8 @@
parent = opendir(folder);
while ((entry = readdir(parent))) {
- if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) ||
- (!strcmp(entry->d_name, "..")))
+ if (!strcmp(entry->d_name, ".") ||
+ !strcmp(entry->d_name, ".."))
continue;
/* first 3 depths are directories only, then files only */
Modified: trunk/netsurf/utils/talloc.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/talloc.h?rev=3154&r1=3153&r...
==============================================================================
--- trunk/netsurf/utils/talloc.h (original)
+++ trunk/netsurf/utils/talloc.h Mon Jan 29 22:27:15 2007
@@ -20,6 +20,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
+#include <unistd.h>
/* this is only needed for compatibility with the old talloc */
typedef void TALLOC_CTX;
Modified: trunk/netsurf/utils/utils.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.c?rev=3154&r1=3153&r2...
==============================================================================
--- trunk/netsurf/utils/utils.c (original)
+++ trunk/netsurf/utils/utils.c Mon Jan 29 22:27:15 2007
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202(a)ecs.soton.ac.uk>
* Copyright 2004 John Tytgat <John.Tytgat(a)aaug.net>
@@ -235,3 +235,30 @@
return NULL;
}
+
+
+#ifdef __FreeBSD__
+
+/**
+ * Duplicate up to n characters of a string.
+ */
+
+char *strndup(const char *s, size_t n)
+{
+ size_t len;
+ char *s2;
+
+ for (len = 0; len != n && s[len]; len++)
+ continue;
+
+ s2 = malloc(len + 1);
+ if (!s2)
+ return 0;
+
+ memcpy(s2, s, len);
+ s2[len] = 0;
+ return s2;
+}
+
+#endif
+
Modified: trunk/netsurf/utils/utils.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.h?rev=3154&r1=3153&r2...
==============================================================================
--- trunk/netsurf/utils/utils.h (original)
+++ trunk/netsurf/utils/utils.h Mon Jan 29 22:27:15 2007
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2004 John Tytgat <John.Tytgat(a)aaug.net>
*/
@@ -56,6 +56,10 @@
char *human_friendly_bytesize(unsigned long bytesize);
const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
+#ifdef __FreeBSD__
+/* FreeBSD lacks strndup */
+char *strndup(const char *s, size_t n);
+#endif
/* Platform specific functions */
void die(const char * const error);
16 years, 8 months
r3153 jmb - /trunk/netsurf/content/urldb.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Jan 28 23:53:20 2007
New Revision: 3153
URL: http://svn.semichrome.net?rev=3153&view=rev
Log:
Handle strdup failure
Modified:
trunk/netsurf/content/urldb.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=3153&r1=3152&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sun Jan 28 23:53:20 2007
@@ -2587,6 +2587,9 @@
/* strip fragment */
urlt = strdup(url);
+ if (!urlt)
+ return false;
+
scheme = strchr(urlt, '#');
if (scheme)
*scheme = '\0';
@@ -2762,7 +2765,8 @@
* \param cookie Pointer to cookie string (updated on exit)
* \return Pointer to cookie structure (on heap, caller frees) or NULL
*/
-struct cookie_internal_data *urldb_parse_cookie(const char *url, const char **cookie)
+struct cookie_internal_data *urldb_parse_cookie(const char *url,
+ const char **cookie)
{
struct cookie_internal_data *c;
const char *cur;
@@ -3267,7 +3271,8 @@
assert(p <= end);
/* Now create cookie */
- struct cookie_internal_data *c = malloc(sizeof(struct cookie_internal_data));
+ struct cookie_internal_data *c =
+ malloc(sizeof(struct cookie_internal_data));
if (!c)
break;
16 years, 8 months
r3152 jmb - /trunk/netsurf/content/urldb.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Jan 28 16:34:50 2007
New Revision: 3152
URL: http://svn.semichrome.net?rev=3152&view=rev
Log:
Improve domain matching of referer and host.
Lose comparison of schemes - this was spurious and wrong.
Fixes 1646417.
Modified:
trunk/netsurf/content/urldb.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=3152&r1=3151&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sun Jan 28 16:34:50 2007
@@ -2613,37 +2613,48 @@
}
if (referer) {
- char *rhost, *rscheme;
+ char *rhost;
/* Ensure that url's host name domain matches
* referer's (4.3.5) */
- res = url_scheme(referer, &rscheme);
+ res = url_host(referer, &rhost);
if (res != URL_FUNC_OK) {
goto error;
}
- res = url_host(referer, &rhost);
- if (res != URL_FUNC_OK) {
- free(rscheme);
- goto error;
- }
-
- if (strcasecmp(scheme, rscheme) != 0) {
- /* Schemes don't match => fail */
- free(rhost);
- free(rscheme);
- goto error;
- }
-
- /* Domain match host names (both are FQDN or IP) */
+ /* Domain match host names */
if (strcasecmp(host, rhost) != 0) {
- free(rhost);
- free(rscheme);
- goto error;
+ /* Not exact match, so try the following:
+ *
+ * 1) host = A.B; rhost = B (i.e. strip first
+ * segment from host and compare against rhost)
+ * 2) host = A.B; rhost = C.B (i.e. strip first
+ * segment off both hosts and compare) */
+ const char *dot = strchr(host, '.');
+ const char *rdot = strchr(host, '.');
+
+ if (!dot || !rdot) {
+ free(rhost);
+ goto error;
+ }
+
+ /* 1 */
+ if (strcasecmp(dot + 1, rhost) != 0) {
+ /* B must contain embedded dots */
+ if (strchr(rdot + 1, '.') == NULL) {
+ free(rhost);
+ goto error;
+ }
+
+ /* 2 */
+ if (strcasecmp(dot, rdot) != 0) {
+ free(rhost);
+ goto error;
+ }
+ }
}
free(rhost);
- free(rscheme);
}
end = cur + strlen(cur) - 2 /* Trailing CRLF */;
16 years, 8 months
r3151 jmb - in /trunk/netsurf: content/content.c content/fetch.c content/fetch.h content/fetchcache.c content/fetchcache.h content/urldb.c content/urldb.h desktop/browser.c desktop/browser.h desktop/frames.c riscos/plugin.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Jan 27 20:58:20 2007
New Revision: 3151
URL: http://svn.semichrome.net?rev=3151&view=rev
Log:
Handle cookies in unverifiable transactions
Modified:
trunk/netsurf/content/content.c
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/content/fetchcache.c
trunk/netsurf/content/fetchcache.h
trunk/netsurf/content/urldb.c
trunk/netsurf/content/urldb.h
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
trunk/netsurf/desktop/frames.c
trunk/netsurf/riscos/plugin.c
Modified: trunk/netsurf/content/content.c
URL: http://svn.semichrome.net/trunk/netsurf/content/content.c?rev=3151&r1=315...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Sat Jan 27 20:58:20 2007
@@ -565,7 +565,8 @@
}
content_remove_user(c, callback, p1, p2);
content_broadcast(clone, CONTENT_MSG_NEWPTR, msg_data);
- fetchcache_go(clone, 0, callback, p1, p2,
+ fetchcache_go(clone, fetch_get_referer(c->fetch),
+ callback, p1, p2,
clone->width, clone->height,
0, 0, false);
}
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3151&r1=3150&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sat Jan 27 20:58:20 2007
@@ -64,9 +64,10 @@
bool abort; /**< Abort requested. */
bool stopped; /**< Download stopped on purpose. */
bool only_2xx; /**< Only HTTP 2xx responses acceptable. */
- bool cookies; /**< Send & accept cookies. */
+ bool verifiable; /**< Transaction is verifiable */
char *url; /**< URL. */
char *referer; /**< URL for Referer header. */
+ bool send_referer; /**< Valid to send the referer */
void *p; /**< Private data for callback. */
struct curl_slist *headers; /**< List of request headers. */
char *host; /**< Host part of URL. */
@@ -299,12 +300,12 @@
* callbacks will contain this.
*/
-struct fetch * fetch_start(char *url, char *referer,
+struct fetch * fetch_start(const char *url, const char *referer,
void (*callback)(fetch_msg msg, void *p, const void *data,
unsigned long size),
- void *p, bool only_2xx, char *post_urlenc,
- struct form_successful_control *post_multipart, bool cookies,
- char *headers[])
+ void *p, bool only_2xx, const char *post_urlenc,
+ struct form_successful_control *post_multipart,
+ bool verifiable, char *headers[])
{
char *host;
struct fetch *fetch;
@@ -355,13 +356,16 @@
fetch->abort = false;
fetch->stopped = false;
fetch->only_2xx = only_2xx;
- fetch->cookies = cookies;
+ fetch->verifiable = verifiable;
fetch->url = strdup(url);
fetch->referer = 0;
+ fetch->send_referer = false;
/* only send the referer if the schemes match */
if (referer) {
- if (ref1 && ref2 && strcasecmp(ref1, ref2) == 0)
- fetch->referer = strdup(referer);
+ fetch->referer = strdup(referer);
+ if (option_send_referer && ref1 && ref2 &&
+ strcasecmp(ref1, ref2) == 0)
+ fetch->send_referer = true;
}
fetch->p = p;
fetch->headers = 0;
@@ -394,9 +398,7 @@
fetch->r_prev = 0;
fetch->r_next = 0;
- if (!fetch->url || (referer &&
- (ref1 && ref2 && strcasecmp(ref1, ref2) == 0) &&
- !fetch->referer) ||
+ if (!fetch->url || (referer && !fetch->referer) ||
(post_urlenc && !fetch->post_urlenc) ||
(post_multipart && !fetch->post_multipart))
goto failed;
@@ -647,7 +649,7 @@
SETOPT(CURLOPT_WRITEDATA, f);
SETOPT(CURLOPT_WRITEHEADER, f);
SETOPT(CURLOPT_PROGRESSDATA, f);
- SETOPT(CURLOPT_REFERER, f->referer);
+ SETOPT(CURLOPT_REFERER, f->send_referer ? f->referer : 0);
SETOPT(CURLOPT_HTTPHEADER, f->headers);
if (f->post_urlenc) {
SETOPT(CURLOPT_POSTFIELDS, f->post_urlenc);
@@ -656,11 +658,11 @@
} else {
SETOPT(CURLOPT_HTTPGET, 1L);
}
- if (f->cookies) {
- f->cookie_string = urldb_get_cookie(f->url, f->referer);
- if (f->cookie_string)
- SETOPT(CURLOPT_COOKIE, f->cookie_string);
- }
+
+ f->cookie_string = urldb_get_cookie(f->url);
+ if (f->cookie_string)
+ SETOPT(CURLOPT_COOKIE, f->cookie_string);
+
#ifdef WITH_AUTH
if ((auth = urldb_get_auth_details(f->url)) != NULL) {
SETOPT(CURLOPT_HTTPAUTH, CURLAUTH_ANY);
@@ -1212,11 +1214,20 @@
f->cachedata.last_modified =
curl_getdate(&data[i], NULL);
}
- } else if (f->cookies && 11 < size &&
- strncasecmp(data, "Set-Cookie:", 11) == 0) {
+ } else if (11 < size && strncasecmp(data, "Set-Cookie:", 11) == 0) {
/* extract Set-Cookie header */
SKIP_ST(11);
- urldb_set_cookie(&data[i], f->url);
+
+ /* If the fetch is unverifiable and there's no referer,
+ * err on the side of caution and do not set the cookie */
+
+ if (f->verifiable || f->referer) {
+ /* If the transaction's verifiable, we don't require
+ * that the request uri and the referer domain match,
+ * so don't pass in the referer in this case. */
+ urldb_set_cookie(&data[i], f->url,
+ f->verifiable ? 0 : f->referer);
+ }
}
return size;
@@ -1451,6 +1462,18 @@
long fetch_http_code(struct fetch *fetch)
{
return fetch->http_code;
+}
+
+
+/**
+ * Get the referer
+ *
+ * \param fetch fetch to retrieve referer from
+ * \return Pointer to referer string, or NULL if none.
+ */
+const char *fetch_get_referer(struct fetch *fetch)
+{
+ return fetch->referer;
}
Modified: trunk/netsurf/content/fetch.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.h?rev=3151&r1=3150&...
==============================================================================
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Sat Jan 27 20:58:20 2007
@@ -66,12 +66,12 @@
extern CURLM *fetch_curl_multi;
void fetch_init(void);
-struct fetch * fetch_start(char *url, char *referer,
+struct fetch * fetch_start(const char *url, const char *referer,
void (*callback)(fetch_msg msg, void *p, const void *data,
unsigned long size),
- void *p, bool only_2xx, char *post_urlenc,
+ void *p, bool only_2xx, const char *post_urlenc,
struct form_successful_control *post_multipart,
- bool cookies, char *headers[]);
+ bool verifiable, char *headers[]);
void fetch_abort(struct fetch *f);
void fetch_poll(void);
void fetch_quit(void);
@@ -83,5 +83,6 @@
unsigned long size),
void *p);
long fetch_http_code(struct fetch *fetch);
+const char *fetch_get_referer(struct fetch *fetch);
#endif
Modified: trunk/netsurf/content/fetchcache.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchcache.c?rev=3151&r1=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Sat Jan 27 20:58:20 2007
@@ -58,7 +58,7 @@
* of generating an error page
* \param post_urlenc url encoded post data, or 0 if none
* \param post_multipart multipart post data, or 0 if none
- * \param cookies send and accept cookies
+ * \param verifiable this transaction is verifiable
* \param download download, rather than render content
* \return a new content, or 0 on memory exhaustion
*
@@ -73,7 +73,7 @@
bool no_error_pages,
char *post_urlenc,
struct form_successful_control *post_multipart,
- bool cookies,
+ bool verifiable,
bool download)
{
struct content *c;
@@ -202,19 +202,19 @@
* \param height available space
* \param post_urlenc url encoded post data, or 0 if none
* \param post_multipart multipart post data, or 0 if none
- * \param cookies send and accept cookies
+ * \param verifiable this transaction is verifiable
*
* Errors will be sent back through the callback.
*/
-void fetchcache_go(struct content *content, char *referer,
+void fetchcache_go(struct content *content, const char *referer,
void (*callback)(content_msg msg, struct content *c,
intptr_t p1, intptr_t p2, union content_msg_data data),
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
struct form_successful_control *post_multipart,
- bool cookies)
+ bool verifiable)
{
char error_message[500];
union content_msg_data msg_data;
@@ -307,7 +307,7 @@
content->fetch = fetch_start(content->url, referer,
fetchcache_callback, content,
content->no_error_pages,
- post_urlenc, post_multipart, cookies,
+ post_urlenc, post_multipart, verifiable,
headers);
for (i = 0; headers[i]; i++)
free(headers[i]);
@@ -745,6 +745,20 @@
else {
/* No cached content, so unconditionally refetch */
struct content_user *u;
+ const char *ref = fetch_get_referer(c->fetch);
+ char *referer = NULL;
+
+ if (ref) {
+ referer = strdup(ref);
+ if (!referer) {
+ c->type = CONTENT_UNKNOWN;
+ c->status = CONTENT_STATUS_ERROR;
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(c, CONTENT_MSG_ERROR,
+ msg_data);
+ return;
+ }
+ }
fetch_abort(c->fetch);
c->fetch = 0;
@@ -754,9 +768,12 @@
c->cache_data->etag = 0;
for (u = c->user_list->next; u; u = u->next) {
- fetchcache_go(c, 0, u->callback, u->p1, u->p2,
- c->width, c->height, 0, 0, false);
- }
+ fetchcache_go(c, referer, u->callback, u->p1, u->p2,
+ c->width, c->height, 0, 0,
+ false);
+ }
+
+ free(referer);
}
}
Modified: trunk/netsurf/content/fetchcache.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchcache.h?rev=3151&r1=...
==============================================================================
--- trunk/netsurf/content/fetchcache.h (original)
+++ trunk/netsurf/content/fetchcache.h Sat Jan 27 20:58:20 2007
@@ -30,15 +30,15 @@
bool no_error_pages,
char *post_urlenc,
struct form_successful_control *post_multipart,
- bool cookies,
+ bool verifiable,
bool download);
-void fetchcache_go(struct content *content, char *referer,
+void fetchcache_go(struct content *content, const char *referer,
void (*callback)(content_msg msg, struct content *c,
intptr_t p1, intptr_t p2, union content_msg_data data),
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
struct form_successful_control *post_multipart,
- bool cookies);
+ bool verifiable);
#endif
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=3151&r1=3150&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sat Jan 27 20:58:20 2007
@@ -2336,12 +2336,9 @@
* Retrieve cookies for an URL
*
* \param url URL being fetched
- * \param referer Referring resource, or NULL
* \return Cookies string for libcurl (on heap), or NULL on error/no cookies
- *
- * \todo Handle unvalidated fetches
- */
-char *urldb_get_cookie(const char *url, const char *referer)
+ */
+char *urldb_get_cookie(const char *url)
{
const struct path_data *p, *q;
const struct host_part *h;
@@ -2356,11 +2353,7 @@
assert(url);
-// LOG(("%s : %s", url, referer));
-
-// if (referer)
-// /* No unvalidated fetches for now */
-// return NULL;
+// LOG(("%s", url));
urldb_add_url(url);
@@ -2455,7 +2448,8 @@
version = c->version;
c->last_used = now;
- cookies_update(c->domain, (struct cookie_data *)c);
+ cookies_update(c->domain,
+ (struct cookie_data *)c);
count++;
}
}
@@ -2577,9 +2571,11 @@
*
* \param header Header to parse, with Set-Cookie: stripped
* \param url URL being fetched
+ * \param referer Referring resource, or 0 for verifiable transaction
* \return true on success, false otherwise
*/
-bool urldb_set_cookie(const char *header, const char *url)
+bool urldb_set_cookie(const char *header, const char *url,
+ const char *referer)
{
const char *cur = header, *end;
char *path, *host, *scheme, *urlt;
@@ -2614,6 +2610,40 @@
free(scheme);
free(urlt);
return false;
+ }
+
+ if (referer) {
+ char *rhost, *rscheme;
+
+ /* Ensure that url's host name domain matches
+ * referer's (4.3.5) */
+ res = url_scheme(referer, &rscheme);
+ if (res != URL_FUNC_OK) {
+ goto error;
+ }
+
+ res = url_host(referer, &rhost);
+ if (res != URL_FUNC_OK) {
+ free(rscheme);
+ goto error;
+ }
+
+ if (strcasecmp(scheme, rscheme) != 0) {
+ /* Schemes don't match => fail */
+ free(rhost);
+ free(rscheme);
+ goto error;
+ }
+
+ /* Domain match host names (both are FQDN or IP) */
+ if (strcasecmp(host, rhost) != 0) {
+ free(rhost);
+ free(rscheme);
+ goto error;
+ }
+
+ free(rhost);
+ free(rscheme);
}
end = cur + strlen(cur) - 2 /* Trailing CRLF */;
Modified: trunk/netsurf/content/urldb.h
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.h?rev=3151&r1=3150&...
==============================================================================
--- trunk/netsurf/content/urldb.h (original)
+++ trunk/netsurf/content/urldb.h Sat Jan 27 20:58:20 2007
@@ -98,8 +98,9 @@
void urldb_dump(void);
/* Cookies */
-bool urldb_set_cookie(const char *header, const char *url);
-char *urldb_get_cookie(const char *url, const char *referer);
+bool urldb_set_cookie(const char *header, const char *url,
+ const char *referer);
+char *urldb_get_cookie(const char *url);
void urldb_delete_cookie(const char *domain, const char *path, const char *name);
void urldb_load_cookies(const char *filename);
void urldb_save_cookies(const char *filename);
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=3151&r1=315...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Sat Jan 27 20:58:20 2007
@@ -59,6 +59,11 @@
/** maximum frame depth */
#define FRAME_DEPTH 8
+static void browser_window_go_post(struct browser_window *bw,
+ const char *url, char *post_urlenc,
+ struct form_successful_control *post_multipart,
+ bool history_add, const char *referer, bool download,
+ bool verifiable);
static void browser_window_callback(content_msg msg, struct content *c,
intptr_t p1, intptr_t p2, union content_msg_data data);
static void browser_window_refresh(void *p);
@@ -111,12 +116,12 @@
*
* \param url URL to start fetching in the new window (copied)
* \param clone The browser window to clone
- * \param referer The referring uri
+ * \param referer The referring uri (copied), or 0 if none
*/
struct browser_window *browser_window_create(const char *url,
struct browser_window *clone,
- char *referer, bool history_add)
+ const char *referer, bool history_add)
{
struct browser_window *bw;
@@ -153,6 +158,7 @@
}
if (url)
browser_window_go(bw, url, referer, history_add);
+
return bw;
}
@@ -162,17 +168,39 @@
*
* \param bw browser window
* \param url URL to start fetching (copied)
- * \param referer the referring uri
+ * \param referer the referring uri (copied), or 0 if none
*
* Any existing fetches in the window are aborted.
*/
void browser_window_go(struct browser_window *bw, const char *url,
- char* referer, bool history_add)
-{
- browser_window_go_post(bw, url, 0, 0, history_add, referer, false);
-}
-
+ const char* referer, bool history_add)
+{
+ /* All fetches passing through here are verifiable
+ * (i.e are the result of user action) */
+ browser_window_go_post(bw, url, 0, 0, history_add, referer,
+ false, true);
+}
+
+
+/**
+ * Start fetching a page in a browser window.
+ *
+ * \param bw browser window
+ * \param url URL to start fetching (copied)
+ * \param referer the referring uri (copied), or 0 if none
+ *
+ * Any existing fetches in the window are aborted.
+ */
+
+void browser_window_go_unverifiable(struct browser_window *bw,
+ const char *url, const char* referer, bool history_add)
+{
+ /* All fetches passing through here are unverifiable
+ * (i.e are not the result of user action) */
+ browser_window_go_post(bw, url, 0, 0, history_add, referer,
+ false, false);
+}
/**
* Start fetching a page in a browser window, POSTing form data.
@@ -182,8 +210,9 @@
* \param post_urlenc url encoded post data, or 0 if none
* \param post_multipart multipart post data, or 0 if none
* \param history_add add to window history
- * \param referer the referring uri
+ * \param referer the referring uri (copied), or 0 if none
* \param download download, rather than render the uri
+ * \param verifiable this transaction is verifiable
*
* Any existing fetches in the window are aborted.
*
@@ -196,7 +225,8 @@
void browser_window_go_post(struct browser_window *bw, const char *url,
char *post_urlenc,
struct form_successful_control *post_multipart,
- bool history_add, char *referer, bool download)
+ bool history_add, const char *referer, bool download,
+ bool verifiable)
{
struct content *c;
char *url2;
@@ -215,7 +245,7 @@
for (cur = bw; cur->parent; cur = cur->parent)
depth++;
if (depth > FRAME_DEPTH) {
- LOG(("frame depth too high."));
+ LOG(("frame depth too high."));
return;
}
@@ -287,7 +317,7 @@
bw->history_add = history_add;
c = fetchcache(url2, browser_window_callback, (intptr_t) bw, 0,
width, height, false,
- post_urlenc, post_multipart, true, download);
+ post_urlenc, post_multipart, verifiable, download);
free(url2);
if (!c) {
browser_window_set_status(bw, messages_get("NoMemory"));
@@ -304,9 +334,9 @@
}
bw->download = download;
- fetchcache_go(c, option_send_referer ? referer : 0,
- browser_window_callback, (intptr_t) bw, 0, width, height,
- post_urlenc, post_multipart, true);
+ fetchcache_go(c, referer, browser_window_callback,
+ (intptr_t) bw, 0, width, height,
+ post_urlenc, post_multipart, verifiable);
}
@@ -318,7 +348,6 @@
intptr_t p1, intptr_t p2, union content_msg_data data)
{
struct browser_window *bw = (struct browser_window *) p1;
- char status[40];
char url[256];
switch (msg) {
@@ -453,7 +482,7 @@
* referer across the redirect */
browser_window_go_post(bw, data.redirect, 0, 0,
bw->history_add, bw->referer,
- bw->download);
+ bw->download, false);
break;
case CONTENT_MSG_REFORMAT:
@@ -462,7 +491,7 @@
/* reposition frames */
if (c->data.html.frameset)
browser_window_recalculate_frameset(bw);
- /* reflow iframe positions */
+ /* reflow iframe positions */
if (c->data.html.iframe)
browser_window_recalculate_iframes(bw);
/* box tree may have changed, need to relabel */
@@ -586,7 +615,7 @@
bw->current_content->refresh)))
history_add = false;
- browser_window_go(bw, bw->current_content->refresh,
+ browser_window_go_unverifiable(bw, bw->current_content->refresh,
bw->current_content->url, history_add);
}
@@ -759,7 +788,7 @@
}
bw->current_content->fresh = false;
browser_window_go_post(bw, bw->current_content->url, 0, 0,
- false, 0, false);
+ false, 0, false, true);
}
@@ -1413,7 +1442,7 @@
mouse & BROWSER_MOUSE_MOD_1) {
/* force download of link */
browser_window_go_post(bw, url, 0, 0, false,
- c->url, true);
+ c->url, true, true);
} else if (mouse & BROWSER_MOUSE_CLICK_1) {
bw = browser_window_find_target(bw, target);
@@ -1426,7 +1455,8 @@
if (!browser_window_href_content.url)
warn_user("NoMemory", 0);
else
- gui_window_save_as_link(bw->window, &browser_window_href_content);
+ gui_window_save_as_link(bw->window,
+ &browser_window_href_content);
} else if (mouse & BROWSER_MOUSE_CLICK_2) {
/* open link in new window */
browser_window_create(url, bw, c->url, true);
@@ -2246,7 +2276,8 @@
warn_user("NoMemory", 0);
return;
}
- url = calloc(1, strlen(form->action) + strlen(data) + 2);
+ url = calloc(1, strlen(form->action) +
+ strlen(data) + 2);
if (!url) {
form_free_successful(success);
free(data);
@@ -2259,8 +2290,8 @@
else {
sprintf(url, "%s?%s", form->action, data);
}
- browser_window_go(bw_form, url, bw->current_content->url,
- true);
+ browser_window_go(bw_form, url,
+ bw->current_content->url, true);
break;
case method_POST_URLENC:
@@ -2272,13 +2303,14 @@
}
browser_window_go_post(bw_form, form->action, data, 0,
true, bw->current_content->url,
- false);
+ false, true);
break;
case method_POST_MULTIPART:
- browser_window_go_post(bw_form, form->action, 0, success,
- true, bw->current_content->url,
- false);
+ browser_window_go_post(bw_form, form->action, 0,
+ success, true,
+ bw->current_content->url,
+ false, true);
break;
default:
Modified: trunk/netsurf/desktop/browser.h
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.h?rev=3151&r1=315...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Sat Jan 27 20:58:20 2007
@@ -123,11 +123,11 @@
/** Window characteristics */
enum {
- BROWSER_WINDOW_NORMAL,
- BROWSER_WINDOW_IFRAME,
- BROWSER_WINDOW_FRAME,
- BROWSER_WINDOW_FRAMESET,
- } browser_window_type;
+ BROWSER_WINDOW_NORMAL,
+ BROWSER_WINDOW_IFRAME,
+ BROWSER_WINDOW_FRAME,
+ BROWSER_WINDOW_FRAMESET,
+ } browser_window_type;
/** frameset characteristics */
int rows;
@@ -179,13 +179,12 @@
extern struct browser_window *current_redraw_browser;
struct browser_window * browser_window_create(const char *url,
- struct browser_window *clone, char *referer, bool history_add);
+ struct browser_window *clone, const char *referer,
+ bool history_add);
void browser_window_go(struct browser_window *bw, const char *url,
- char *referer, bool history_add);
-void browser_window_go_post(struct browser_window *bw, const char *url,
- char *post_urlenc,
- struct form_successful_control *post_multipart,
- bool history_add, char *referer, bool download);
+ const char *referer, bool history_add);
+void browser_window_go_unverifiable(struct browser_window *bw,
+ const char *url, const char *referer, bool history_add);
void browser_window_update(struct browser_window *bw, bool scroll_to_top);
void browser_window_stop(struct browser_window *bw);
void browser_window_reload(struct browser_window *bw, bool all);
Modified: trunk/netsurf/desktop/frames.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/frames.c?rev=3151&r1=3150...
==============================================================================
--- trunk/netsurf/desktop/frames.c (original)
+++ trunk/netsurf/desktop/frames.c Sat Jan 27 20:58:20 2007
@@ -99,7 +99,8 @@
for (cur = iframe; cur; cur = cur->next) {
window = &(bw->iframes[index++]);
if (cur->url)
- browser_window_go(window, cur->url, NULL, true);
+ browser_window_go_unverifiable(window, cur->url,
+ bw->current_content->url, true);
}
}
@@ -148,6 +149,7 @@
int row, col, index;
struct content_html_frames *frame;
struct browser_window *window;
+ const char *referer;
assert(bw && frameset);
@@ -174,9 +176,11 @@
/* window characteristics */
window->drag_type = DRAGGING_NONE;
if (frame->children)
- window->browser_window_type = BROWSER_WINDOW_FRAMESET;
+ window->browser_window_type =
+ BROWSER_WINDOW_FRAMESET;
else
- window->browser_window_type = BROWSER_WINDOW_FRAME;
+ window->browser_window_type =
+ BROWSER_WINDOW_FRAME;
window->scrolling = frame->scrolling;
window->border = frame->border;
window->border_colour = frame->border_colour;
@@ -212,6 +216,18 @@
}
}
+ /* Use the URL of the first ancestor window containing html content
+ * as the referer */
+ for (window = bw; window->parent; window = window->parent) {
+ if (window->current_content &&
+ window->current_content->type == CONTENT_HTML)
+ break;
+ }
+ if (window->current_content)
+ referer = window->current_content->url;
+ else
+ referer = NULL;
+
/* 4. Launch content */
for (row = 0; row < bw->rows; row++) {
for (col = 0; col < bw->cols; col++) {
@@ -219,8 +235,12 @@
frame = &frameset->children[index];
window = &bw->children[index];
- if (frame->url)
- browser_window_go(window, frame->url, NULL, true);
+ if (frame->url) {
+ browser_window_go_unverifiable(window,
+ frame->url,
+ referer,
+ true);
+ }
}
}
}
Modified: trunk/netsurf/riscos/plugin.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/plugin.c?rev=3151&r1=3150&...
==============================================================================
--- trunk/netsurf/riscos/plugin.c (original)
+++ trunk/netsurf/riscos/plugin.c Sat Jan 27 20:58:20 2007
@@ -1651,7 +1651,7 @@
}
c = fetchcache(url2, plugin_stream_callback, (intptr_t)p, 0,
- 100, 100, true, 0, 0, true, true);
+ 100, 100, true, 0, 0, false, true);
free(url2);
if (!c) {
return false;
@@ -1659,7 +1659,7 @@
p->c = c;
fetchcache_go(c, 0, plugin_stream_callback, (intptr_t)p, 0,
- 100, 100, 0, 0, true);
+ 100, 100, 0, 0, false);
return true;
}
16 years, 8 months