diff options
-rwxr-xr-x | amiga/gui_options.c | 6 | ||||
-rw-r--r-- | desktop/netsurf.c | 2 | ||||
-rw-r--r-- | desktop/options.h | 2 | ||||
-rw-r--r-- | gtk/dialogs/preferences.c | 23 | ||||
-rw-r--r-- | gtk/res/options.gtk2.ui | 8 | ||||
-rw-r--r-- | gtk/res/options.gtk3.ui | 6 | ||||
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/nsurl.c | 1 | ||||
-rw-r--r-- | utils/nsoption.h | 3 | ||||
-rw-r--r-- | utils/nsurl.c | 83 |
10 files changed, 100 insertions, 36 deletions
diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 0b01a93d4..3a6451b97 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -1157,7 +1157,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_DISC] = IntegerObject, GA_ID, GID_OPTS_CACHE_DISC, GA_RelVerify, TRUE, - INTEGER_Number, nsoption_int(disc_cache_size) / 1048576, + INTEGER_Number, nsoption_uint(disc_cache_size) / 1048576, INTEGER_Minimum, 0, INTEGER_Maximum, 4096, INTEGER_Arrows, TRUE, @@ -1750,8 +1750,8 @@ void ami_gui_opts_use(bool save) GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size)); nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_size)); - nsoption_set_int(disc_cache_size, nsoption_int(disc_cache_size) * 1048576); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_uint(disc_cache_size)); + nsoption_set_uint(disc_cache_size, nsoption_uint(disc_cache_size) * 1048576); GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data); if (data) { diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 153810705..a1bc42b93 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -191,7 +191,7 @@ nserror netsurf_init(const char *messages, const char *store_path) hlcache_parameters.llcache.limit -= image_cache_parameters.limit; /* set backing store target limit */ - hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size); + hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size); /* set backing store hysterissi to 20% */ hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;; diff --git a/desktop/options.h b/desktop/options.h index 391dfbc08..33ecb7554 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -89,7 +89,7 @@ NSOPTION_STRING(accept_charset, NULL) NSOPTION_INTEGER(memory_cache_size, 12 * 1024 * 1024) /** Preferred expiry size of disc cache / bytes. */ -NSOPTION_INTEGER(disc_cache_size, 1024 * 1024 * 1024) +NSOPTION_UINT(disc_cache_size, 1024 * 1024 * 1024) /** Preferred expiry age of disc cache / days. */ NSOPTION_INTEGER(disc_cache_age, 28) diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c index f80500dfa..58bb8b4d9 100644 --- a/gtk/dialogs/preferences.c +++ b/gtk/dialogs/preferences.c @@ -108,6 +108,27 @@ nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \ ((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \ } +#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \ + struct ppref *priv); \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \ + struct ppref *priv) \ +{ \ + nsoption_set_uint(OPTION, \ + round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \ +} \ + \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \ +{ \ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \ + ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \ +} + #define ENTRY_SIGNALS(WIDGET, OPTION) \ G_MODULE_EXPORT void \ nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \ @@ -372,7 +393,7 @@ SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0) SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024)) /* disc cache size */ -SPINBUTTON_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024)) +SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024)) /* disc cache age */ diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui index ebe7b91f5..b0d45bb2f 100644 --- a/gtk/res/options.gtk2.ui +++ b/gtk/res/options.gtk2.ui @@ -2653,10 +2653,10 @@ <property name="page_increment">16</property> </object> <object class="GtkAdjustment" id="adjustment_cache_disc_size"> - <property name="value">16</property> - <property name="upper">2048</property> - <property name="step_increment">4</property> - <property name="page_increment">16</property> + <property name="value">1024</property> + <property name="upper">4096</property> + <property name="step_increment">32</property> + <property name="page_increment">256</property> </object> <object class="GtkAdjustment" id="adjustment_disc_cache_age"> <property name="value">28</property> diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui index a795c2bf5..02e4df47c 100644 --- a/gtk/res/options.gtk3.ui +++ b/gtk/res/options.gtk3.ui @@ -9,13 +9,13 @@ <property name="page_increment">1</property> </object> <object class="GtkAdjustment" id="adjustment_cache_disc_size"> - <property name="upper">2048</property> - <property name="value">16</property> + <property name="upper">4096</property> + <property name="value">1024</property> <property name="step_increment">4</property> <property name="page_increment">16</property> </object> <object class="GtkAdjustment" id="adjustment_cache_memory_size"> - <property name="upper">2048</property> + <property name="upper">1024</property> <property name="value">16</property> <property name="step_increment">4</property> <property name="page_increment">16</property> diff --git a/test/Makefile b/test/Makefile index acf9d4e65..cf0f89724 100644 --- a/test/Makefile +++ b/test/Makefile @@ -22,7 +22,7 @@ urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \ urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2 urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom) -nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c test/nsurl.c +nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c utils/utf8proc.c test/nsurl.c nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom) diff --git a/test/nsurl.c b/test/nsurl.c index 3e859d994..20774c41f 100644 --- a/test/nsurl.c +++ b/test/nsurl.c @@ -141,6 +141,7 @@ static const struct test_pairs join_tests[] = { { " / ", "http://a/" }, { " ? ", "http://a/b/c/d;p?" }, { " h ", "http://a/b/c/h" }, + { "http://<!--#echo var=", "http://<!--/#echo%20var="}, /* [1] Extra slash beyond rfc3986 5.4.1 example, since we're * testing normalisation in addition to joining */ /* [2] Using the strict parsers option */ diff --git a/utils/nsoption.h b/utils/nsoption.h index d111729aa..134223aa5 100644 --- a/utils/nsoption.h +++ b/utils/nsoption.h @@ -308,6 +308,9 @@ int nsoption_snoptionf(char *string, size_t size, enum nsoption_e option, const /** set an integer option in the default table */ #define nsoption_set_int(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.i = VALUE +/** set an unsigned integer option in the default table */ +#define nsoption_set_uint(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.u = VALUE + /** set a colour option in the default table */ #define nsoption_set_colour(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.c = VALUE diff --git a/utils/nsurl.c b/utils/nsurl.c index 7e8792cff..591907fad 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -685,6 +685,7 @@ static nserror nsurl__create_from_section(const char * const url_s, char *pos_norm, struct nsurl_components *url) { + nserror ret; int ascii_offset; int start = 0; int end = 0; @@ -961,14 +962,20 @@ static nserror nsurl__create_from_section(const char * const url_s, /* host */ /* Encode host according to IDNA2008 */ - if (idna_encode(norm_start, length, &host, &host_len) == NSERROR_OK) { + ret = idna_encode(norm_start, length, &host, &host_len); + if (ret == NSERROR_OK) { + /* valid idna encoding */ if (lwc_intern_string(host, host_len, &url->host) != lwc_error_ok) { return NSERROR_NOMEM; } free(host); } else { - return NSERROR_BAD_URL; + /* fall back to straight interning */ + if (lwc_intern_string(norm_start, length, + &url->host) != lwc_error_ok) { + return NSERROR_NOMEM; + } } } @@ -1736,6 +1743,10 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) assert(base != NULL); assert(rel != NULL); +#ifdef NSURL_DEBUG + LOG(("base: \"%s\", rel: \"%s\"", nsurl_access(base), rel)); +#endif + /* Peg out the URL sections */ nsurl__get_string_markers(rel, &m, true); @@ -1743,11 +1754,13 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) length = nsurl__get_longest_section(&m); /* Initially assume that the joined URL can be formed entierly from - * the relative URL. */ + * the relative URL. + */ joined_parts = NSURL_F_REL; /* Update joined_compnents to indicate any required parts from the - * base URL. */ + * base URL. + */ if (m.scheme_end - m.start <= 0) { /* The relative url has no scheme. * Use base URL's scheme. */ @@ -1777,7 +1790,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) } /* Allocate enough memory to url escape the longest section, plus - * space for path merging (if required). */ + * space for path merging (if required). + */ if (joined_parts & NSURL_F_MERGED_PATH) { /* Need to merge paths */ length += (base->components.path != NULL) ? @@ -1789,8 +1803,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) lwc_string_length(base->components.path) : 0); buff = malloc(length + 5); - if (buff == NULL) + if (buff == NULL) { return NSERROR_NOMEM; + } buff_pos = buff; @@ -1803,8 +1818,11 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) } else { c.scheme_type = m.scheme_type; - error |= nsurl__create_from_section(rel, URL_SCHEME, &m, - buff, &c); + error = nsurl__create_from_section(rel, URL_SCHEME, &m, buff, &c); + if (error != NSERROR_OK) { + free(buff); + return error; + } } if (joined_parts & NSURL_F_BASE_AUTHORITY) { @@ -1813,10 +1831,16 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) c.host = nsurl__component_copy(base->components.host); c.port = nsurl__component_copy(base->components.port); } else { - error |= nsurl__create_from_section(rel, URL_CREDENTIALS, &m, - buff, &c); - error |= nsurl__create_from_section(rel, URL_HOST, &m, - buff, &c); + error = nsurl__create_from_section(rel, URL_CREDENTIALS, &m, + buff, &c); + if (error == NSERROR_OK) { + error = nsurl__create_from_section(rel, URL_HOST, &m, + buff, &c); + } + if (error != NSERROR_OK) { + free(buff); + return error; + } } if (joined_parts & NSURL_F_BASE_PATH) { @@ -1866,8 +1890,12 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) m_path.query = new_length; buff_start = buff_pos + new_length; - error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path, + error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path, buff_start, &c); + if (error != NSERROR_OK) { + free(buff); + return error; + } } else { struct url_markers m_path; @@ -1883,24 +1911,34 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) m_path.query = new_length; buff_start = buff_pos + new_length; - error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path, + + error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path, buff_start, &c); + if (error != NSERROR_OK) { + free(buff); + return error; + } } - if (joined_parts & NSURL_F_BASE_QUERY) + if (joined_parts & NSURL_F_BASE_QUERY) { c.query = nsurl__component_copy(base->components.query); - else - error |= nsurl__create_from_section(rel, URL_QUERY, &m, + } else { + error = nsurl__create_from_section(rel, URL_QUERY, &m, buff, &c); + if (error != NSERROR_OK) { + free(buff); + return error; + } + } - error |= nsurl__create_from_section(rel, URL_FRAGMENT, &m, - buff, &c); + error = nsurl__create_from_section(rel, URL_FRAGMENT, &m, buff, &c); /* Free temporary buffer */ free(buff); - if (error != NSERROR_OK) - return NSERROR_NOMEM; + if (error != NSERROR_OK) { + return error; + } /* Get the string length and find which parts of url are present */ nsurl__get_string_data(&c, NSURL_WITH_FRAGMENT, &length, @@ -1908,8 +1946,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) /* Create NetSurf URL object */ *joined = malloc(sizeof(nsurl) + length + 1); /* Add 1 for \0 */ - if (*joined == NULL) + if (*joined == NULL) { return NSERROR_NOMEM; + } (*joined)->components = c; (*joined)->length = length; |