libcss: branch tlsa/jmb/mq updated. release/0.7.0-35-g842ae56
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/842ae56d81e1e90f393be4...
...commit http://git.netsurf-browser.org/libcss.git/commit/842ae56d81e1e90f393be442...
...tree http://git.netsurf-browser.org/libcss.git/tree/842ae56d81e1e90f393be44201...
The branch, tlsa/jmb/mq has been updated
via 842ae56d81e1e90f393be44201c9b83b9d7b5f92 (commit)
from a4d73071ae2d810107defe8c209687b12dac003a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=842ae56d81e1e90f393b...
commit 842ae56d81e1e90f393be44201c9b83b9d7b5f92
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Documentation: Add new units to bytecode docs.
diff --git a/docs/Bytecode b/docs/Bytecode
index f64656a..dd0f424 100644
--- a/docs/Bytecode
+++ b/docs/Bytecode
@@ -69,6 +69,7 @@ Length is a 32bit numeric value (as described above) and unit is as follows:
00000000 => deg
00000001 => grad
00000010 => rad
+ 00000011 => turn
bit 10 set => time unit
bits 11-31: MBZ
@@ -84,6 +85,14 @@ Length is a 32bit numeric value (as described above) and unit is as follows:
00000000 => Hz
00000001 => kHz
+ bit 12 set => resolution unit
+ bits 13-31: MBZ
+ bits 8-11 : MBZ
+ bits 0-7 :
+ 00000000 => dpi
+ 00000001 => dpcm
+ 00000010 => dppx
+
CSS colours are stored as one 32bit value. See "Colour" for their format.
Shorthand properties
-----------------------------------------------------------------------
Summary of changes:
docs/Bytecode | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/docs/Bytecode b/docs/Bytecode
index f64656a..dd0f424 100644
--- a/docs/Bytecode
+++ b/docs/Bytecode
@@ -69,6 +69,7 @@ Length is a 32bit numeric value (as described above) and unit is as follows:
00000000 => deg
00000001 => grad
00000010 => rad
+ 00000011 => turn
bit 10 set => time unit
bits 11-31: MBZ
@@ -84,6 +85,14 @@ Length is a 32bit numeric value (as described above) and unit is as follows:
00000000 => Hz
00000001 => kHz
+ bit 12 set => resolution unit
+ bits 13-31: MBZ
+ bits 8-11 : MBZ
+ bits 0-7 :
+ 00000000 => dpi
+ 00000001 => dpcm
+ 00000010 => dppx
+
CSS colours are stored as one 32bit value. See "Colour" for their format.
Shorthand properties
--
Cascading Style Sheets library
5 years, 7 months
libcss: branch tlsa/jmb/mq updated. release/0.7.0-34-ga4d7307
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/a4d73071ae2d810107defe...
...commit http://git.netsurf-browser.org/libcss.git/commit/a4d73071ae2d810107defe8c...
...tree http://git.netsurf-browser.org/libcss.git/tree/a4d73071ae2d810107defe8c20...
The branch, tlsa/jmb/mq has been updated
discards f1d2dfec8a0ffe90171c547b912613388538f273 (commit)
via a4d73071ae2d810107defe8c209687b12dac003a (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (f1d2dfec8a0ffe90171c547b912613388538f273)
\
N -- N -- N (a4d73071ae2d810107defe8c209687b12dac003a)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=a4d73071ae2d810107de...
commit a4d73071ae2d810107defe8c209687b12dac003a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: Implement parsing <general-enclosed>.
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 719e129..6692651 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -433,14 +433,111 @@ static css_error mq_parse_media_feature(css_language *c,
return CSS_OK;
}
+/*
+ * Consume any value
+ *
+ * CSS Syntax Module Level 3: 8.2
+ */
+static css_error mq_parse_consume_any_value(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ bool until, const char until_char)
+{
+ const css_token *token;
+ css_error error;
+
+ while (true) {
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_INVALID_STRING:
+ return CSS_INVALID;
+
+ case CSS_TOKEN_CHAR:
+ if (until && tokenIsChar(token, until_char)) {
+ /* Found matching close bracket */
+ return CSS_OK;
+
+ } else if (tokenIsChar(token, ')') ||
+ tokenIsChar(token, ']') ||
+ tokenIsChar(token, '}')) {
+ /* Non-matching close bracket */
+ return CSS_INVALID;
+ }
+ if (tokenIsChar(token, '(')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, true, ')');
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '[')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, true, ']');
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '{')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, true, '}');
+ if (error != CSS_OK) {
+ return error;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return CSS_OK;
+}
+
static css_error mq_parse_general_enclosed(css_language *c,
const parserutils_vector *vector, int *ctx)
{
+ const css_token *token;
+ css_error error;
+
/* <general-enclosed> = [ <function-token> <any-value> ) ]
* | ( <ident> <any-value> )
*/
- /* TODO: implement */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_FUNCTION:
+ error = mq_parse_consume_any_value(c, vector, ctx, true, ')');
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (!tokenIsChar(token, ')')) {
+ return CSS_INVALID;
+ }
+ break;
+
+ case CSS_TOKEN_IDENT:
+ error = mq_parse_consume_any_value(c, vector, ctx, false, '\0');
+ if (error != CSS_OK) {
+ return error;
+ }
+ break;
+
+ default:
+ return CSS_INVALID;
+ }
return CSS_OK;
}
-----------------------------------------------------------------------
Summary of changes:
src/parse/mq.c | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 172b618..6692651 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -440,7 +440,7 @@ static css_error mq_parse_media_feature(css_language *c,
*/
static css_error mq_parse_consume_any_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- const char *until_char)
+ bool until, const char until_char)
{
const css_token *token;
css_error error;
@@ -458,39 +458,34 @@ static css_error mq_parse_consume_any_value(css_language *c,
return CSS_INVALID;
case CSS_TOKEN_CHAR:
- if (until_char != NULL) {
- if (tokenIsChar(token, *until_char)) {
- /* Found matching close bracket */
- return CSS_OK;
-
- } else if (tokenIsChar(token, ')') ||
- tokenIsChar(token, ']') ||
- tokenIsChar(token, '}')) {
- /* Non-matching close bracket */
- return CSS_INVALID;
- } else if (tokenIsChar(token, ';')) {
- /* Non-top-level semi-colon */
- return CSS_INVALID;
- }
+ if (until && tokenIsChar(token, until_char)) {
+ /* Found matching close bracket */
+ return CSS_OK;
+
+ } else if (tokenIsChar(token, ')') ||
+ tokenIsChar(token, ']') ||
+ tokenIsChar(token, '}')) {
+ /* Non-matching close bracket */
+ return CSS_INVALID;
}
if (tokenIsChar(token, '(')) {
/* Need to consume until matching bracket. */
error = mq_parse_consume_any_value(
- c, vector, ctx, ")");
+ c, vector, ctx, true, ')');
if (error != CSS_OK) {
return error;
}
} else if (tokenIsChar(token, '[')) {
/* Need to consume until matching bracket. */
error = mq_parse_consume_any_value(
- c, vector, ctx, "]");
+ c, vector, ctx, true, ']');
if (error != CSS_OK) {
return error;
}
} else if (tokenIsChar(token, '{')) {
/* Need to consume until matching bracket. */
error = mq_parse_consume_any_value(
- c, vector, ctx, "}");
+ c, vector, ctx, true, '}');
if (error != CSS_OK) {
return error;
}
@@ -522,21 +517,19 @@ static css_error mq_parse_general_enclosed(css_language *c,
switch (token->type) {
case CSS_TOKEN_FUNCTION:
- error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ error = mq_parse_consume_any_value(c, vector, ctx, true, ')');
if (error != CSS_OK) {
return error;
}
- consumeWhitespace(vector, ctx);
-
- token = parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
if (!tokenIsChar(token, ')')) {
return CSS_INVALID;
}
break;
case CSS_TOKEN_IDENT:
- error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ error = mq_parse_consume_any_value(c, vector, ctx, false, '\0');
if (error != CSS_OK) {
return error;
}
--
Cascading Style Sheets library
5 years, 7 months
netsurf: branch master updated. release/3.7-71-g5094a3f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5094a3fd048e06a49bb23...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5094a3fd048e06a49bb232a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5094a3fd048e06a49bb232ae7...
The branch, master has been updated
via 5094a3fd048e06a49bb232ae7eb09821c512c8a0 (commit)
via 83e8f377ad4fd99bab6da6eca0228762bc4e630e (commit)
from 42f5bb6182f90313eceb3c1b60bfd4792bbba3d5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5094a3fd048e06a49bb...
commit 5094a3fd048e06a49bb232ae7eb09821c512c8a0
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Rework use of split-messages to clean up and use -z
diff --git a/Makefile b/Makefile
index 0ce9cdd..a4c5949 100644
--- a/Makefile
+++ b/Makefile
@@ -651,16 +651,12 @@ S_COMMON := \
# Message splitting rule generation macro
# 1 = Language
define split_messages
-.INTERMEDIATE:$$(MESSAGES_TARGET)/$(1)/Messages.tmp
-$$(MESSAGES_TARGET)/$(1)/Messages.tmp: resources/FatMessages
+$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages
$$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
$$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
- $$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ $$<
-
-$$(MESSAGES_TARGET)/$(1)/Messages: $$(MESSAGES_TARGET)/$(1)/Messages.tmp
- $$(VQ)echo "COMPRESS: $$@"
- $$(Q)gzip -9n < $$< > $$@
+ $$(Q)$$(RM) $$@
+ $$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
diff --git a/frontends/atari/Makefile b/frontends/atari/Makefile
index a2f27e2..f07543e 100644
--- a/frontends/atari/Makefile
+++ b/frontends/atari/Makefile
@@ -177,7 +177,8 @@ endif
$(Q)cp \!NetSurf/Resources/internal.css,f79 $(ATARI_TARGET_DIR)res/internal.css
$(Q)cp \!NetSurf/Resources/SearchEngines $(ATARI_TARGET_DIR)res/search
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
- $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(RM) $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages -o $(ATARI_TARGET_DIR)res/messages resources/FatMessages
$(Q)cp \!NetSurf/Resources/en/welcome.html,faf $(ATARI_TARGET_DIR)res/welcome.html
$(Q)cp \!NetSurf/Resources/en/maps.html,faf $(ATARI_TARGET_DIR)res/maps.html
$(Q)cp \!NetSurf/Resources/en/licence.html,faf $(ATARI_TARGET_DIR)res/licence.html
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 323ca6c..055ef90 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -177,7 +177,8 @@ install-framebuffer:
$(Q)$(MKDIR) -p $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)
$(Q)cp -v $(EXETARGET) $(DESTDIR)/$(NETSURF_FRAMEBUFFER_BIN)netsurf-fb
$(Q)for F in $(NETSURF_FRAMEBUFFER_RESOURCE_LIST); do cp -vL $(FRONTEND_RESOURCES_DIR)/$$F $(DESTDIR)/$(NETSURF_FRAMEBUFFER_RESOURCES); done
- $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(RM) $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages -o $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages -z resources/FatMessages
# ----------------------------------------------------------------------------
# Package target
diff --git a/frontends/windows/Makefile b/frontends/windows/Makefile
index 50d0d4b..de01ce3 100644
--- a/frontends/windows/Makefile
+++ b/frontends/windows/Makefile
@@ -84,6 +84,7 @@ endif
# installer messages generation
$(OBJROOT)/messages-en: resources/FatMessages
$(VQ)echo "MSGSPLIT: Language: en Filter: win"
+ $(Q)$(RM) $@
$(Q)$(SPLIT_MESSAGES) -l en -p win -f messages -o $@ $<
netsurf-installer.exe: $(EXETARGET) $(WIN_RES_INS_OBJ)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=83e8f377ad4fd99bab6...
commit 83e8f377ad4fd99bab6da6eca0228762bc4e630e
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Support compression on output stream
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 570ae03..4b50dde 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -34,6 +34,8 @@ use strict;
use Getopt::Long ();
use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY );
+use IO::Compress::Gzip;
+
use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling );
use constant GETOPT_SPEC =>
qw( output|o=s
@@ -43,6 +45,7 @@ use constant GETOPT_SPEC =>
plat|platform|p=s
format|fmt|f=s
warning|W=s
+ gzip|z
help|h|? );
# default option values:
@@ -214,7 +217,7 @@ sub input_stream ()
return \*STDIN;
}
-sub output_stream ()
+sub underlying_output_stream ()
{
if( $opt{output} )
{
@@ -229,6 +232,18 @@ sub output_stream ()
return \*STDOUT;
}
+sub output_stream ()
+{
+ my $ofh = underlying_output_stream();
+
+ if( $opt{gzip} )
+ {
+ $ofh = new IO::Compress::Gzip( $ofh, AutoClose => 1, -Level => 9 );
+ }
+
+ return $ofh;
+}
+
sub formatter ()
{
my $name = $opt{format};
-----------------------------------------------------------------------
Summary of changes:
Makefile | 10 +++-------
frontends/atari/Makefile | 3 ++-
frontends/framebuffer/Makefile | 3 ++-
frontends/windows/Makefile | 1 +
utils/split-messages.pl | 17 ++++++++++++++++-
5 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 0ce9cdd..a4c5949 100644
--- a/Makefile
+++ b/Makefile
@@ -651,16 +651,12 @@ S_COMMON := \
# Message splitting rule generation macro
# 1 = Language
define split_messages
-.INTERMEDIATE:$$(MESSAGES_TARGET)/$(1)/Messages.tmp
-$$(MESSAGES_TARGET)/$(1)/Messages.tmp: resources/FatMessages
+$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages
$$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
$$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
- $$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ $$<
-
-$$(MESSAGES_TARGET)/$(1)/Messages: $$(MESSAGES_TARGET)/$(1)/Messages.tmp
- $$(VQ)echo "COMPRESS: $$@"
- $$(Q)gzip -9n < $$< > $$@
+ $$(Q)$$(RM) $$@
+ $$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
diff --git a/frontends/atari/Makefile b/frontends/atari/Makefile
index a2f27e2..f07543e 100644
--- a/frontends/atari/Makefile
+++ b/frontends/atari/Makefile
@@ -177,7 +177,8 @@ endif
$(Q)cp \!NetSurf/Resources/internal.css,f79 $(ATARI_TARGET_DIR)res/internal.css
$(Q)cp \!NetSurf/Resources/SearchEngines $(ATARI_TARGET_DIR)res/search
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
- $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(RM) $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages -o $(ATARI_TARGET_DIR)res/messages resources/FatMessages
$(Q)cp \!NetSurf/Resources/en/welcome.html,faf $(ATARI_TARGET_DIR)res/welcome.html
$(Q)cp \!NetSurf/Resources/en/maps.html,faf $(ATARI_TARGET_DIR)res/maps.html
$(Q)cp \!NetSurf/Resources/en/licence.html,faf $(ATARI_TARGET_DIR)res/licence.html
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 323ca6c..055ef90 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -177,7 +177,8 @@ install-framebuffer:
$(Q)$(MKDIR) -p $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)
$(Q)cp -v $(EXETARGET) $(DESTDIR)/$(NETSURF_FRAMEBUFFER_BIN)netsurf-fb
$(Q)for F in $(NETSURF_FRAMEBUFFER_RESOURCE_LIST); do cp -vL $(FRONTEND_RESOURCES_DIR)/$$F $(DESTDIR)/$(NETSURF_FRAMEBUFFER_RESOURCES); done
- $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(RM) $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages -o $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages -z resources/FatMessages
# ----------------------------------------------------------------------------
# Package target
diff --git a/frontends/windows/Makefile b/frontends/windows/Makefile
index 50d0d4b..de01ce3 100644
--- a/frontends/windows/Makefile
+++ b/frontends/windows/Makefile
@@ -84,6 +84,7 @@ endif
# installer messages generation
$(OBJROOT)/messages-en: resources/FatMessages
$(VQ)echo "MSGSPLIT: Language: en Filter: win"
+ $(Q)$(RM) $@
$(Q)$(SPLIT_MESSAGES) -l en -p win -f messages -o $@ $<
netsurf-installer.exe: $(EXETARGET) $(WIN_RES_INS_OBJ)
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 570ae03..4b50dde 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -34,6 +34,8 @@ use strict;
use Getopt::Long ();
use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY );
+use IO::Compress::Gzip;
+
use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling );
use constant GETOPT_SPEC =>
qw( output|o=s
@@ -43,6 +45,7 @@ use constant GETOPT_SPEC =>
plat|platform|p=s
format|fmt|f=s
warning|W=s
+ gzip|z
help|h|? );
# default option values:
@@ -214,7 +217,7 @@ sub input_stream ()
return \*STDIN;
}
-sub output_stream ()
+sub underlying_output_stream ()
{
if( $opt{output} )
{
@@ -229,6 +232,18 @@ sub output_stream ()
return \*STDOUT;
}
+sub output_stream ()
+{
+ my $ofh = underlying_output_stream();
+
+ if( $opt{gzip} )
+ {
+ $ofh = new IO::Compress::Gzip( $ofh, AutoClose => 1, -Level => 9 );
+ }
+
+ return $ofh;
+}
+
sub formatter ()
{
my $name = $opt{format};
--
NetSurf Browser
5 years, 7 months
netsurf: branch jmb/hsts created. release/3.7-76-gcbe445e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/cbe445e19178045c0bdf6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/cbe445e19178045c0bdf649...
...tree http://git.netsurf-browser.org/netsurf.git/tree/cbe445e19178045c0bdf649f9...
The branch, jmb/hsts has been created
at cbe445e19178045c0bdf649f927e6e7cc904c6c5 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cbe445e19178045c0bd...
commit cbe445e19178045c0bdf649f927e6e7cc904c6c5
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
HSTS: make llcache update policy on 3xx responses
diff --git a/content/llcache.c b/content/llcache.c
index 166804c..54f20e0 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1985,6 +1985,8 @@ static nserror llcache_fetch_redirect(llcache_object *object,
/* And mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
+ (void) llcache_hsts_update_policy(object);
+
/* Forcibly stop redirecting if we've followed too many redirects */
#define REDIRECT_LIMIT 10
if (object->fetch.redirect_count > REDIRECT_LIMIT) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c42ea9b30d8197f688e...
commit c42ea9b30d8197f688eec80c974575eb213a35e6
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
HSTS: prevent llcache being nice
If the server has defined a HSTS policy, then the user no longer
gets to click-through a garbage certificate. Additionally, if
the server has provided a HSTS policy, it should do TLS properly,
so don't permit client-driven TLS version downgrades in that case,
either.
diff --git a/content/llcache.c b/content/llcache.c
index ab69e65..166804c 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -109,6 +109,8 @@ typedef struct {
uint32_t retries_remaining; /**< Number of times to retry on timeout */
+ bool hsts_in_use; /**< Whether HSTS applies to this fetch */
+
bool tried_with_auth; /**< Whether we've tried with auth */
bool tried_with_tls_downgrade; /**< Whether we've tried TLS <= 1.0 */
@@ -904,11 +906,12 @@ static nserror llcache_object_refetch(llcache_object *object)
* \param referer Referring URL, or NULL for none
* \param post POST data, or NULL for GET
* \param redirect_count Number of redirects followed so far
+ * \param hsts_in_use Whether HSTS applies to this fetch
* \return NSERROR_OK on success, appropriate error otherwise
*/
static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
nsurl *referer, const llcache_post_data *post,
- uint32_t redirect_count)
+ uint32_t redirect_count, bool hsts_in_use)
{
nserror error;
nsurl *referer_clone = NULL;
@@ -930,6 +933,7 @@ static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
object->fetch.post = post_clone;
object->fetch.redirect_count = redirect_count;
object->fetch.retries_remaining = llcache->fetch_attempts;
+ object->fetch.hsts_in_use = hsts_in_use;
return llcache_object_refetch(object);
}
@@ -1566,6 +1570,7 @@ llcache_object_fetch_persistent(llcache_object *object,
* \param referer Referring URL, or NULL if none
* \param post POST data, or NULL for a GET request
* \param redirect_count Number of redirects followed so far
+ * \param hsts_in_use Whether HSTS applies to this fetch
* \param result Pointer to location to receive retrieved object
* \return NSERROR_OK on success, appropriate error otherwise
*/
@@ -1575,6 +1580,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
nsurl *referer,
const llcache_post_data *post,
uint32_t redirect_count,
+ bool hsts_in_use,
llcache_object **result)
{
nserror error;
@@ -1683,7 +1689,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
/* Attempt to kick-off fetch */
error = llcache_object_fetch(obj, flags, referer, post,
- redirect_count);
+ redirect_count, hsts_in_use);
if (error != NSERROR_OK) {
newest->candidate_count--;
llcache_object_destroy(obj);
@@ -1715,7 +1721,8 @@ llcache_object_retrieve_from_cache(nsurl *url,
}
/* Attempt to kick-off fetch */
- error = llcache_object_fetch(obj, flags, referer, post, redirect_count);
+ error = llcache_object_fetch(obj, flags, referer, post,
+ redirect_count, hsts_in_use);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
return error;
@@ -1737,6 +1744,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
* \param referer Referring URL, or NULL if none
* \param post POST data, or NULL for a GET request
* \param redirect_count Number of redirects followed so far
+ * \param hsts_in_use Whether HSTS applies to this fetch
* \param result Pointer to location to receive retrieved object
* \return NSERROR_OK on success, appropriate error otherwise
*/
@@ -1746,6 +1754,7 @@ llcache_object_retrieve(nsurl *url,
nsurl *referer,
const llcache_post_data *post,
uint32_t redirect_count,
+ bool hsts_in_use,
llcache_object **result)
{
nserror error;
@@ -1800,7 +1809,7 @@ llcache_object_retrieve(nsurl *url,
/* Attempt to kick-off fetch */
error = llcache_object_fetch(obj, flags, referer, post,
- redirect_count);
+ redirect_count, hsts_in_use);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
nsurl_unref(defragmented_url);
@@ -1811,7 +1820,8 @@ llcache_object_retrieve(nsurl *url,
llcache_object_add_to_list(obj, &llcache->uncached_objects);
} else {
error = llcache_object_retrieve_from_cache(defragmented_url,
- flags, referer, post, redirect_count, &obj);
+ flags, referer, post, redirect_count,
+ hsts_in_use, &obj);
if (error != NSERROR_OK) {
nsurl_unref(defragmented_url);
return error;
@@ -2058,7 +2068,8 @@ static nserror llcache_fetch_redirect(llcache_object *object,
/* Attempt to fetch target URL */
error = llcache_object_retrieve(hsts_url, object->fetch.flags,
object->fetch.referer, post,
- object->fetch.redirect_count + 1, &dest);
+ object->fetch.redirect_count + 1,
+ hsts_in_use, &dest);
/* No longer require url */
nsurl_unref(hsts_url);
@@ -2352,7 +2363,8 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
/* Consider the TLS transport tainted */
object->fetch.tainted_tls = true;
- if (llcache->query_cb != NULL) {
+ /* Only give the user a chance if HSTS isn't in use for this fetch */
+ if (object->fetch.hsts_in_use == false && llcache->query_cb != NULL) {
llcache_query query;
/* Emit query for TLS */
@@ -2405,7 +2417,10 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
/* Consider the TLS transport tainted */
object->fetch.tainted_tls = true;
- if (object->fetch.tried_with_tls_downgrade == true) {
+ /* Make no attempt to downgrade if HSTS is in use
+ * (i.e. assume server does TLS properly) */
+ if (object->fetch.hsts_in_use ||
+ object->fetch.tried_with_tls_downgrade) {
/* Have already tried to downgrade, so give up */
llcache_event event;
@@ -3611,7 +3626,8 @@ nserror llcache_handle_retrieve(nsurl *url, uint32_t flags,
/* Retrieve a suitable object from the cache,
* creating a new one if needed. */
- error = llcache_object_retrieve(hsts_url, flags, referer, post, 0, &object);
+ error = llcache_object_retrieve(hsts_url, flags, referer, post, 0,
+ hsts_in_use, &object);
if (error != NSERROR_OK) {
llcache_object_user_destroy(user);
nsurl_unref(hsts_url);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=99a29000b937807c7f9...
commit 99a29000b937807c7f946d597295c96733ff60f3
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
HSTS: teach llcache to update and enforce policy.
diff --git a/content/llcache.c b/content/llcache.c
index 58803ea..ab69e65 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -114,6 +114,8 @@ typedef struct {
bool tried_with_tls_downgrade; /**< Whether we've tried TLS <= 1.0 */
bool outstanding_query; /**< Waiting for a query response */
+
+ bool tainted_tls; /**< Whether the TLS transport is tainted */
} llcache_fetch_ctx;
/**
@@ -1857,6 +1859,90 @@ static nserror llcache_object_add_user(llcache_object *object,
}
/**
+ * Transform a request-URI based on HSTS policy
+ *
+ * \param url URL to transform
+ * \param result Pointer to location to receive transformed URL
+ * \param hsts_in_use Pointer to location to receive HSTS in-use flag
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror llcache_hsts_transform_url(nsurl *url, nsurl **result,
+ bool *hsts_in_use)
+{
+ lwc_string *scheme = NULL;
+ bool match;
+ nserror error = NSERROR_OK;;
+
+ scheme = nsurl_get_component(url, NSURL_SCHEME);
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_http,
+ &match) != lwc_error_ok || match == false) {
+ /* Non-HTTP fetch: ignore */
+ if (scheme != NULL) {
+ lwc_string_unref(scheme);
+ }
+ *result = nsurl_ref(url);
+ *hsts_in_use = false;
+ return NSERROR_OK;
+ }
+ lwc_string_unref(scheme);
+
+ if (urldb_get_hsts_enabled(url)) {
+ /* Only need to force HTTPS. If original port was explicitly
+ * specified as 80, nsurl_create/join will remove it (as
+ * it's redundant) */
+ error = nsurl_replace_scheme(url, corestring_lwc_https,
+ result);
+ *hsts_in_use = (error == NSERROR_OK);
+ } else {
+ *result = nsurl_ref(url);
+ *hsts_in_use = false;
+ }
+
+ return error;
+}
+
+/**
+ * Update HSTS policy for target domain.
+ *
+ * \param object Newly-fetched cache object
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror llcache_hsts_update_policy(llcache_object *object)
+{
+ size_t i;
+ lwc_string *scheme = NULL;
+ bool match = false;
+
+ scheme = nsurl_get_component(object->url, NSURL_SCHEME);
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_https,
+ &match) != lwc_error_ok || match == false) {
+ /* Non-HTTPS fetch: ignore */
+ if (scheme != NULL) {
+ lwc_string_unref(scheme);
+ }
+ return NSERROR_OK;
+ }
+ lwc_string_unref(scheme);
+
+ if (object->fetch.tainted_tls) {
+ /* Transport is tainted: ignore */
+ return NSERROR_OK;
+ }
+
+ for (i = 0; i < object->num_headers; i++) {
+ if (strcasecmp("Strict-Transport-Security",
+ object->headers[i].name) == 0) {
+ urldb_set_hsts_policy(object->url,
+ object->headers[i].value);
+ /* Only process the first one we find */
+ break;
+ }
+ }
+
+ return NSERROR_OK;
+}
+
+/**
* Handle FETCH_REDIRECT event
*
* \param object Object being redirected
@@ -1871,10 +1957,10 @@ static nserror llcache_fetch_redirect(llcache_object *object,
llcache_object *dest;
llcache_object_user *user, *next;
const llcache_post_data *post = object->fetch.post;
- nsurl *url;
+ nsurl *url, *hsts_url;
lwc_string *scheme;
lwc_string *object_scheme;
- bool match;
+ bool match, hsts_in_use;
/* Extract HTTP response code from the fetch object */
long http_code = fetch_http_code(object->fetch.fetch);
llcache_event event;
@@ -1906,15 +1992,23 @@ static nserror llcache_fetch_redirect(llcache_object *object,
if (error != NSERROR_OK)
return error;
+ /* Perform HSTS transform */
+ error = llcache_hsts_transform_url(url, &hsts_url, &hsts_in_use);
+ if (error != NSERROR_OK) {
+ nsurl_unref(url);
+ return error;
+ }
+ nsurl_unref(url);
+
/* Inform users of redirect */
event.type = LLCACHE_EVENT_REDIRECT;
event.data.redirect.from = object->url;
- event.data.redirect.to = url;
+ event.data.redirect.to = hsts_url;
error = llcache_send_event_to_users(object, &event);
if (error != NSERROR_OK) {
- nsurl_unref(url);
+ nsurl_unref(hsts_url);
return error;
}
@@ -1922,7 +2016,7 @@ static nserror llcache_fetch_redirect(llcache_object *object,
* A "validated" scheme is one over which we have some guarantee that
* the source is trustworthy. */
object_scheme = nsurl_get_component(object->url, NSURL_SCHEME);
- scheme = nsurl_get_component(url, NSURL_SCHEME);
+ scheme = nsurl_get_component(hsts_url, NSURL_SCHEME);
/* resource: and about: are allowed to redirect anywhere */
if ((lwc_string_isequal(object_scheme, corestring_lwc_resource,
@@ -1938,7 +2032,7 @@ static nserror llcache_fetch_redirect(llcache_object *object,
&match) == lwc_error_ok && match == true)) {
lwc_string_unref(object_scheme);
lwc_string_unref(scheme);
- nsurl_unref(url);
+ nsurl_unref(hsts_url);
return NSERROR_OK;
}
}
@@ -1947,8 +2041,8 @@ static nserror llcache_fetch_redirect(llcache_object *object,
lwc_string_unref(object_scheme);
/* Bail out if we've no way of handling this URL */
- if (fetch_can_fetch(url) == false) {
- nsurl_unref(url);
+ if (fetch_can_fetch(hsts_url) == false) {
+ nsurl_unref(hsts_url);
return NSERROR_OK;
}
@@ -1957,17 +2051,17 @@ static nserror llcache_fetch_redirect(llcache_object *object,
post = NULL;
} else if (http_code != 307 || post != NULL) {
/** \todo 300, 305, 307 with POST */
- nsurl_unref(url);
+ nsurl_unref(hsts_url);
return NSERROR_OK;
}
/* Attempt to fetch target URL */
- error = llcache_object_retrieve(url, object->fetch.flags,
+ error = llcache_object_retrieve(hsts_url, object->fetch.flags,
object->fetch.referer, post,
object->fetch.redirect_count + 1, &dest);
/* No longer require url */
- nsurl_unref(url);
+ nsurl_unref(hsts_url);
if (error != NSERROR_OK)
return error;
@@ -2059,6 +2153,8 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
/* Mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
+ (void) llcache_hsts_update_policy(object);
+
/* Old object will be flushed from the cache on the next poll */
return NSERROR_OK;
@@ -2253,6 +2349,9 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
/* Invalidate cache-control data */
llcache_invalidate_cache_control_data(object);
+ /* Consider the TLS transport tainted */
+ object->fetch.tainted_tls = true;
+
if (llcache->query_cb != NULL) {
llcache_query query;
@@ -2303,6 +2402,9 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
/* Invalidate cache-control data */
llcache_invalidate_cache_control_data(object);
+ /* Consider the TLS transport tainted */
+ object->fetch.tainted_tls = true;
+
if (object->fetch.tried_with_tls_downgrade == true) {
/* Have already tried to downgrade, so give up */
llcache_event event;
@@ -2684,6 +2786,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
/* record when the fetch finished */
object->cache.fin_time = time(NULL);
+ (void) llcache_hsts_update_policy(object);
+
guit->misc->schedule(5000, llcache_persist, NULL);
}
break;
@@ -3483,23 +3587,34 @@ nserror llcache_handle_retrieve(nsurl *url, uint32_t flags,
nserror error;
llcache_object_user *user;
llcache_object *object;
+ nsurl *hsts_url;
+ bool hsts_in_use;
+
+ /* Perform HSTS transform */
+ error = llcache_hsts_transform_url(url, &hsts_url, &hsts_in_use);
+ if (error != NSERROR_OK) {
+ return error;
+ }
/* Can we fetch this URL at all? */
- if (fetch_can_fetch(url) == false) {
+ if (fetch_can_fetch(hsts_url) == false) {
+ nsurl_unref(hsts_url);
return NSERROR_NO_FETCH_HANDLER;
}
/* Create a new object user */
error = llcache_object_user_new(cb, pw, &user);
if (error != NSERROR_OK) {
+ nsurl_unref(hsts_url);
return error;
}
/* Retrieve a suitable object from the cache,
* creating a new one if needed. */
- error = llcache_object_retrieve(url, flags, referer, post, 0, &object);
+ error = llcache_object_retrieve(hsts_url, flags, referer, post, 0, &object);
if (error != NSERROR_OK) {
llcache_object_user_destroy(user);
+ nsurl_unref(hsts_url);
return error;
}
@@ -3511,6 +3626,8 @@ nserror llcache_handle_retrieve(nsurl *url, uint32_t flags,
/* Users exist which are now not caught up! */
llcache_users_not_caught_up();
+ nsurl_unref(hsts_url);
+
return NSERROR_OK;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7d7bcb526bc8df9f570...
commit 7d7bcb526bc8df9f5705e6a37711eef20da84df1
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
NSURL: add ability to create replacement scheme
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index 8d15eeb..90dd796 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -70,6 +70,7 @@ CORESTRING_LWC_STRING(filename);
CORESTRING_LWC_STRING(font);
CORESTRING_LWC_STRING(frame);
CORESTRING_LWC_STRING(frameset);
+CORESTRING_LWC_STRING(ftp);
CORESTRING_LWC_STRING(h1);
CORESTRING_LWC_STRING(h2);
CORESTRING_LWC_STRING(h3);
diff --git a/utils/nsurl.h b/utils/nsurl.h
index f97562b..054baf2 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -301,6 +301,25 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
/**
+ * Create a NetSurf URL object, with scheme replaced
+ *
+ * \param url NetSurf URL to create new NetSurf URL from
+ * \param scheme Scheme to use
+ * \param new_url Returns new NetSurf URL with scheme provided
+ * \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * If return value != NSERROR_OK, nothing will be returned in new_url.
+ *
+ * It is up to the client to call nsurl_unref when they are finished with
+ * the created object.
+ *
+ * Any scheme component in url is replaced with scheme in new_url.
+ */
+nserror nsurl_replace_scheme(const nsurl *url, lwc_string *scheme,
+ nsurl **new_url);
+
+
+/**
* Attempt to find a nice filename for a URL.
*
* \param url A NetSurf URL object to create a filename from
diff --git a/utils/nsurl/nsurl.c b/utils/nsurl/nsurl.c
index 3b0af93..8c769cf 100644
--- a/utils/nsurl/nsurl.c
+++ b/utils/nsurl/nsurl.c
@@ -648,6 +648,93 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
}
+/* exported interface, documented in nsurl.h */
+nserror nsurl_replace_scheme(const nsurl *url, lwc_string *scheme,
+ nsurl **new_url)
+{
+ int scheme_len;
+ int base_len;
+ char *pos;
+ size_t len;
+ bool match;
+
+ assert(url != NULL);
+ assert(scheme != NULL);
+
+ /* Get the length of the new scheme */
+ scheme_len = lwc_string_length(scheme);
+
+ /* Find the change in length from url to new_url */
+ base_len = url->length;
+ if (url->components.scheme != NULL) {
+ base_len -= lwc_string_length(url->components.scheme);
+ }
+
+ /* Set new_url's length */
+ len = base_len + scheme_len;
+
+ /* Create NetSurf URL object */
+ *new_url = malloc(sizeof(nsurl) + len + 1); /* Add 1 for \0 */
+ if (*new_url == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ (*new_url)->length = len;
+
+ /* Set string */
+ pos = (*new_url)->string;
+ memcpy(pos, lwc_string_data(scheme), scheme_len);
+ memcpy(pos + scheme_len,
+ url->string + url->length - base_len, base_len);
+ pos[len] = '\0';
+
+ /* Copy components */
+ (*new_url)->components.scheme = lwc_string_ref(scheme);
+ (*new_url)->components.username =
+ nsurl__component_copy(url->components.username);
+ (*new_url)->components.password =
+ nsurl__component_copy(url->components.password);
+ (*new_url)->components.host =
+ nsurl__component_copy(url->components.host);
+ (*new_url)->components.port =
+ nsurl__component_copy(url->components.port);
+ (*new_url)->components.path =
+ nsurl__component_copy(url->components.path);
+ (*new_url)->components.query =
+ nsurl__component_copy(url->components.query);
+ (*new_url)->components.fragment =
+ nsurl__component_copy(url->components.fragment);
+
+ /* Compute new scheme type */
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_http,
+ &match) == lwc_error_ok && match == true) {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_HTTP;
+ } else if (lwc_string_caseless_isequal(scheme, corestring_lwc_https,
+ &match) == lwc_error_ok && match == true) {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_HTTPS;
+ } else if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
+ &match) == lwc_error_ok && match == true) {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_FILE;
+ } else if (lwc_string_caseless_isequal(scheme, corestring_lwc_ftp,
+ &match) == lwc_error_ok && match == true) {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_FTP;
+ } else if (lwc_string_caseless_isequal(scheme, corestring_lwc_mailto,
+ &match) == lwc_error_ok && match == true) {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_MAILTO;
+ } else {
+ (*new_url)->components.scheme_type = NSURL_SCHEME_OTHER;
+ }
+
+ /* Get the nsurl's hash */
+ nsurl__calc_hash(*new_url);
+
+ /* Give the URL a reference */
+ (*new_url)->count = 1;
+
+ return NSERROR_OK;
+}
+
+
/* exported interface documented in utils/nsurl.h */
nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
{
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=447e2aa4cb0468907f8...
commit 447e2aa4cb0468907f8996d4e02fb34d19c29510
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
HSTS: support policy in urldb
diff --git a/content/urldb.c b/content/urldb.c
index cacc475..1bf2233 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -108,6 +108,7 @@
#include "utils/time.h"
#include "utils/nsurl.h"
#include "utils/ascii.h"
+#include "utils/http.h"
#include "netsurf/bitmap.h"
#include "desktop/cookie_manager.h"
#include "desktop/gui_internal.h"
@@ -222,6 +223,11 @@ struct path_data {
struct path_data *last; /**< Last child */
};
+struct hsts_data {
+ time_t expires; /**< Expiry time */
+ bool include_sub_domains; /**< Whether to include subdomains */
+};
+
struct host_part {
/**
* Known paths on this host. This _must_ be first so that
@@ -233,6 +239,8 @@ struct host_part {
* without verifying certificate authenticity
*/
bool permit_invalid_certs;
+ /* HSTS data */
+ struct hsts_data hsts;
/**
* Part of host string
@@ -290,7 +298,7 @@ static int loaded_cookie_file_version;
/** Minimum URL database file version */
#define MIN_URL_FILE_VERSION 106
/** Current URL database file version */
-#define URL_FILE_VERSION 106
+#define URL_FILE_VERSION 107
/**
* filter for url presence in database
@@ -511,7 +519,8 @@ static void urldb_save_search_tree(struct search_node *parent, FILE *fp)
unsigned int path_count = 0;
char *path, *p, *end;
int path_alloc = 64, path_used = 1;
- time_t expiry;
+ time_t expiry, hsts_expiry = 0;
+ int hsts_include_subdomains = 0;
expiry = time(NULL) - ((60 * 60 * 24) * nsoption_int(expire_url));
@@ -537,13 +546,25 @@ static void urldb_save_search_tree(struct search_node *parent, FILE *fp)
p += written;
}
+ h = parent->data;
+ if (h && h->hsts.expires > expiry) {
+ hsts_expiry = h->hsts.expires;
+ hsts_include_subdomains = h->hsts.include_sub_domains;
+ }
+
urldb_count_urls(&parent->data->paths, expiry, &path_count);
if (path_count > 0) {
- fprintf(fp, "%s\n%i\n", host, path_count);
+ fprintf(fp, "%s %i ", host, hsts_include_subdomains);
+ urldb_write_timet(fp, hsts_expiry);
+ fprintf(fp, "%i\n", path_count);
urldb_write_paths(&parent->data->paths, host, fp,
&path, &path_alloc, &path_used, expiry);
+ } else if (hsts_expiry) {
+ fprintf(fp, "%s %i ", host, hsts_include_subdomains);
+ urldb_write_timet(fp, hsts_expiry);
+ fprintf(fp, "0\n");
}
free(path);
@@ -2894,6 +2915,9 @@ nserror urldb_load(const char *filename)
}
while (fgets(host, sizeof host, fp)) {
+ time_t hsts_expiry = 0;
+ int hsts_include_sub_domains = 0;
+
/* get the hostname */
length = strlen(host) - 1;
host[length] = '\0';
@@ -2911,6 +2935,25 @@ nserror urldb_load(const char *filename)
continue;
}
+ if (version >= 107) {
+ char *p = host;
+ while (*p && *p != ' ') p++;
+ while (*p && *p == ' ') { *p = '\0'; p++; }
+ hsts_include_sub_domains = (*p == '1');
+ while (*p && *p != ' ') p++;
+ while (*p && *p == ' ') p++;
+ nsc_snptimet(p, strlen(p), &hsts_expiry);
+ }
+
+ h = urldb_add_host(host);
+ if (!h) {
+ NSLOG(netsurf, INFO, "Failed adding host: '%s'", host);
+ fclose(fp);
+ return NSERROR_NOMEM;
+ }
+ h->hsts.expires = hsts_expiry;
+ h->hsts.include_sub_domains = hsts_include_sub_domains;
+
/* read number of URLs */
if (!fgets(s, MAXIMUM_URL_LENGTH, fp))
break;
@@ -2922,13 +2965,6 @@ nserror urldb_load(const char *filename)
continue;
}
- h = urldb_add_host(host);
- if (!h) {
- NSLOG(netsurf, INFO, "Failed adding host: '%s'", host);
- fclose(fp);
- return NSERROR_NOMEM;
- }
-
/* load the non-corrupt data */
for (i = 0; i < urls; i++) {
struct path_data *p = NULL;
@@ -3460,6 +3496,131 @@ bool urldb_get_cert_permissions(nsurl *url)
}
+/* exported interface documented in content/urldb.h */
+bool urldb_set_hsts_policy(struct nsurl *url, const char *header)
+{
+ struct path_data *p;
+ struct host_part *h;
+ lwc_string *host;
+ time_t now = time(NULL);
+ http_strict_transport_security *sts;
+ uint32_t max_age = 0;
+ nserror error;
+
+ assert(url);
+
+ host = nsurl_get_component(url, NSURL_HOST);
+ if (host != NULL) {
+ if (urldb__host_is_ip_address(lwc_string_data(host))) {
+ /* Host is IP: ignore */
+ lwc_string_unref(host);
+ return true;
+ }
+
+ lwc_string_unref(host);
+ }
+
+ /* add url, in case it's missing */
+ urldb_add_url(url);
+
+ p = urldb_find_url(url);
+ if (!p)
+ return false;
+
+ for (; p && p->parent; p = p->parent)
+ /* do nothing */;
+ assert(p);
+
+ h = (struct host_part *)p;
+ if (h->permit_invalid_certs) {
+ /* Transport is tainted: ignore */
+ return true;
+ }
+
+ error = http_parse_strict_transport_security(header, &sts);
+ if (error != NSERROR_OK) {
+ /* Parse failed: ignore */
+ return true;
+ }
+
+ h->hsts.include_sub_domains =
+ http_strict_transport_security_include_subdomains(sts);
+
+ max_age = http_strict_transport_security_max_age(sts);
+ if (max_age == 0) {
+ h->hsts.expires = 0;
+ h->hsts.include_sub_domains = false;
+ } else if (now + max_age > h->hsts.expires) {
+ h->hsts.expires = now + max_age;
+ }
+
+ http_strict_transport_security_destroy(sts);
+
+ return true;
+}
+
+
+/* exported interface documented in content/urldb.h */
+bool urldb_get_hsts_enabled(struct nsurl *url)
+{
+ struct path_data *p;
+ const struct host_part *h;
+ lwc_string *host;
+ time_t now = time(NULL);
+
+ assert(url);
+
+ host = nsurl_get_component(url, NSURL_HOST);
+ if (host != NULL) {
+ if (urldb__host_is_ip_address(lwc_string_data(host))) {
+ /* Host is IP: not enabled */
+ lwc_string_unref(host);
+ return false;
+ } else if (lwc_string_length(host) == 0) {
+ /* Host is blank: not enabled */
+ lwc_string_unref(host);
+ return false;
+ }
+
+ lwc_string_unref(host);
+ } else {
+ /* No host part: not enabled */
+ return false;
+ }
+
+ /* The URL must exist in the db in order to find HSTS policy, since
+ * we search up the tree from the URL node, and policy from further
+ * up may also apply. */
+ urldb_add_url(url);
+
+ p = urldb_find_url(url);
+ if (!p)
+ return false;
+
+ for (; p && p->parent; p = p->parent)
+ /* do nothing */;
+ assert(p);
+
+ h = (const struct host_part *)p;
+
+ /* Consult record for this host */
+ if (h->hsts.expires > now) {
+ /* Not expired */
+ return true;
+ }
+
+ /* Consult parent domains */
+ for (h = h->parent; h && h != &db_root; h = h->parent) {
+ if (h->hsts.expires > now && h->hsts.include_sub_domains) {
+ /* Not expired and subdomains included */
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
/* exported interface documented in netsurf/url_db.h */
void
urldb_iterate_partial(const char *prefix,
diff --git a/content/urldb.h b/content/urldb.h
index 4aa5487..0ad6426 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -131,4 +131,22 @@ bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl *refer
char *urldb_get_cookie(struct nsurl *url, bool include_http_only);
+/**
+ * Set HSTS policy for an URL
+ *
+ * \param url URL being fetched
+ * \param header Strict-Transport-Security header value
+ * \return true on success, false otherwise
+ */
+bool urldb_set_hsts_policy(struct nsurl *url, const char *header);
+
+
+/**
+ * Determine if HSTS policy is enabled for an URL
+ *
+ * \param url URL being fetched
+ * \return true if HSTS policy is enabled, false otherwise
+ */
+bool urldb_get_hsts_enabled(struct nsurl *url);
+
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7d1c92069e3a85f1c34...
commit 7d1c92069e3a85f1c340c52c050487ec0073d200
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
HSTS: add parser for Strict-Transport-Security
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index def5a73..8d15eeb 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -86,6 +86,7 @@ CORESTRING_LWC_STRING(icon);
CORESTRING_LWC_STRING(iframe);
CORESTRING_LWC_STRING(image);
CORESTRING_LWC_STRING(img);
+CORESTRING_LWC_STRING(includesubdomains);
CORESTRING_LWC_STRING(input);
CORESTRING_LWC_STRING(javascript);
CORESTRING_LWC_STRING(justify);
@@ -141,6 +142,7 @@ CORESTRING_LWC_STRING(_top);
/* unusual lwc strings */
CORESTRING_LWC_VALUE(shortcut_icon, "shortcut icon");
CORESTRING_LWC_VALUE(slash_, "/");
+CORESTRING_LWC_VALUE(max_age, "max-age");
/* mime types */
CORESTRING_LWC_VALUE(multipart_form_data, "multipart/form-data");
diff --git a/utils/http.h b/utils/http.h
index 173604f..00caf89 100644
--- a/utils/http.h
+++ b/utils/http.h
@@ -29,6 +29,7 @@
#include "utils/http/content-disposition.h"
#include "utils/http/content-type.h"
+#include "utils/http/strict-transport-security.h"
#include "utils/http/www-authenticate.h"
#endif
diff --git a/utils/http/Makefile b/utils/http/Makefile
index 198588b..f3bb765 100644
--- a/utils/http/Makefile
+++ b/utils/http/Makefile
@@ -1,6 +1,7 @@
# http utils sources
S_HTTP := challenge.c generics.c primitives.c parameter.c \
- content-disposition.c content-type.c www-authenticate.c
+ content-disposition.c content-type.c \
+ strict-transport-security.c www-authenticate.c
-S_HTTP := $(addprefix utils/http/,$(S_HTTP))
\ No newline at end of file
+S_HTTP := $(addprefix utils/http/,$(S_HTTP))
diff --git a/utils/http/challenge.c b/utils/http/challenge.c
index 578532e..9b85fcc 100644
--- a/utils/http/challenge.c
+++ b/utils/http/challenge.c
@@ -92,7 +92,7 @@ nserror http__parse_challenge(const char **input, http_challenge **challenge)
http__skip_LWS(&pos);
if (*pos == ',') {
- error = http__item_list_parse(&pos,
+ error = http__item_list_parse(&pos,
http__parse_parameter, first, ¶ms);
if (error != NSERROR_OK && error != NSERROR_NOT_FOUND) {
lwc_string_unref(scheme);
diff --git a/utils/http/content-disposition.c b/utils/http/content-disposition.c
index 5d5e94c..03bd12b 100644
--- a/utils/http/content-disposition.c
+++ b/utils/http/content-disposition.c
@@ -45,7 +45,7 @@ nserror http_parse_content_disposition(const char *header_value,
http__skip_LWS(&pos);
if (*pos == ';') {
- error = http__item_list_parse(&pos,
+ error = http__item_list_parse(&pos,
http__parse_parameter, NULL, ¶ms);
if (error != NSERROR_OK && error != NSERROR_NOT_FOUND) {
lwc_string_unref(mtype);
diff --git a/utils/http/content-type.c b/utils/http/content-type.c
index f84da8c..d4279f5 100644
--- a/utils/http/content-type.c
+++ b/utils/http/content-type.c
@@ -68,7 +68,7 @@ nserror http_parse_content_type(const char *header_value,
http__skip_LWS(&pos);
if (*pos == ';') {
- error = http__item_list_parse(&pos,
+ error = http__item_list_parse(&pos,
http__parse_parameter, NULL, ¶ms);
if (error != NSERROR_OK && error != NSERROR_NOT_FOUND) {
lwc_string_unref(subtype);
diff --git a/utils/http/generics.h b/utils/http/generics.h
index 8c391c4..a5af734 100644
--- a/utils/http/generics.h
+++ b/utils/http/generics.h
@@ -19,6 +19,8 @@
#ifndef NETSURF_UTILS_HTTP_GENERICS_H_
#define NETSURF_UTILS_HTTP_GENERICS_H_
+#include <stdbool.h>
+
#include "utils/errors.h"
/**
diff --git a/utils/http/strict-transport-security.c b/utils/http/strict-transport-security.c
new file mode 100644
index 0000000..64caf66
--- /dev/null
+++ b/utils/http/strict-transport-security.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright 2018 John-Mark Bell <jmb(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include "utils/corestrings.h"
+#include "utils/http.h"
+
+#include "utils/http/generics.h"
+#include "utils/http/primitives.h"
+
+/**
+ * Representation of a Strict-Transport-Security
+ */
+struct http_strict_transport_security {
+ uint32_t max_age; /**< Max age (delta seconds) */
+ bool include_sub_domains; /**< Whether subdomains are included */
+};
+
+/**
+ * Representation of a directive
+ */
+typedef struct http_directive {
+ http__item base;
+
+ lwc_string *name; /**< Parameter name */
+ lwc_string *value; /**< Parameter value (optional) */
+} http_directive;
+
+
+static void http_destroy_directive(http_directive *self)
+{
+ lwc_string_unref(self->name);
+ if (self->value != NULL) {
+ lwc_string_unref(self->value);
+ }
+ free(self);
+}
+
+static nserror http__parse_directive(const char **input,
+ http_directive **result)
+{
+ const char *pos = *input;
+ lwc_string *name;
+ lwc_string *value = NULL;
+ http_directive *directive;
+ nserror error;
+
+ /* token [ "=" ( token | quoted-string ) ] */
+
+ error = http__parse_token(&pos, &name);
+ if (error != NSERROR_OK)
+ return error;
+
+ http__skip_LWS(&pos);
+
+ if (*pos == '=') {
+ pos++;
+
+ http__skip_LWS(&pos);
+
+ if (*pos == '"')
+ error = http__parse_quoted_string(&pos, &value);
+ else
+ error = http__parse_token(&pos, &value);
+
+ if (error != NSERROR_OK) {
+ lwc_string_unref(name);
+ return error;
+ }
+ }
+
+ directive = malloc(sizeof(*directive));
+ if (directive == NULL) {
+ if (value != NULL) {
+ lwc_string_unref(value);
+ }
+ lwc_string_unref(name);
+ return NSERROR_NOMEM;
+ }
+
+ HTTP__ITEM_INIT(directive, NULL, http_destroy_directive);
+ directive->name = name;
+ directive->value = value;
+
+ *result = directive;
+ *input = pos;
+
+ return NSERROR_OK;
+}
+
+static void http_directive_list_destroy(http_directive *list)
+{
+ http__item_list_destroy(list);
+}
+
+static nserror http_directive_list_find_item(const http_directive *list,
+ lwc_string *name, lwc_string **value)
+{
+ bool match;
+
+ while (list != NULL) {
+ if (lwc_string_caseless_isequal(name, list->name,
+ &match) == lwc_error_ok && match)
+ break;
+
+ list = (http_directive *) list->base.next;
+ }
+
+ if (list == NULL)
+ return NSERROR_NOT_FOUND;
+
+ if (list->value != NULL) {
+ *value = lwc_string_ref(list->value);
+ } else {
+ *value = NULL;
+ }
+
+ return NSERROR_OK;
+}
+
+static const http_directive *http_directive_list_iterate(
+ const http_directive *cur,
+ lwc_string **name, lwc_string **value)
+{
+ if (cur == NULL)
+ return NULL;
+
+ *name = lwc_string_ref(cur->name);
+ if (cur->value != NULL) {
+ *value = lwc_string_ref(cur->value);
+ } else {
+ *value = NULL;
+ }
+
+ return (http_directive *) cur->base.next;
+}
+
+static uint32_t count(const http_directive *list, lwc_string *key)
+{
+ uint32_t count = 0;
+ bool match;
+
+ while (list != NULL) {
+ if (lwc_string_caseless_isequal(key, list->name,
+ &match) == lwc_error_ok && match) {
+ count++;
+ }
+
+ list = (http_directive *) list->base.next;
+ }
+
+ return count;
+}
+
+static bool check_duplicates(const http_directive *directives)
+{
+ bool result = true;
+ const http_directive *key = directives;
+
+ do {
+ lwc_string *name = NULL, *value = NULL;
+
+ key = http_directive_list_iterate(key, &name, &value);
+
+ result &= (count(directives, name) == 1);
+
+ lwc_string_unref(name);
+ if (value != NULL) {
+ lwc_string_unref(value);
+ }
+ } while (key != NULL);
+
+ return result;
+}
+
+static nserror parse_max_age(lwc_string *value, uint32_t *result)
+{
+ const char *pos = lwc_string_data(value);
+ const char *end = pos + lwc_string_length(value);
+ uint32_t val = 0;
+
+ /* 1*DIGIT */
+
+ if (pos == end) {
+ /* Blank value */
+ return NSERROR_NOT_FOUND;
+ }
+
+ while (pos < end) {
+ if ('0' <= *pos && *pos <= '9') {
+ uint32_t nv = val * 10 + (*pos - '0');
+ if (nv < val) {
+ val = UINT_MAX;
+ } else {
+ val = nv;
+ }
+ } else {
+ /* Non-digit */
+ return NSERROR_NOT_FOUND;
+ }
+
+ pos++;
+ }
+
+ *result = val;
+
+ return NSERROR_OK;
+}
+
+/* See strict-transport-security.h for documentation */
+nserror http_parse_strict_transport_security(const char *header_value,
+ http_strict_transport_security **result)
+{
+ const char *pos = header_value;
+ http_strict_transport_security *sts;
+ http_directive *first = NULL;
+ http_directive *directives = NULL;
+ lwc_string *max_age_str = NULL, *isd_str = NULL;
+ uint32_t max_age;
+ bool include_sub_domains = false;
+ nserror error;
+
+ /* directive *( ";" directive ) */
+
+ http__skip_LWS(&pos);
+
+ error = http__parse_directive(&pos, &first);
+ if (error != NSERROR_OK) {
+ return error;
+ }
+
+ http__skip_LWS(&pos);
+
+ if (*pos == ';') {
+ error = http__item_list_parse(&pos,
+ http__parse_directive, first, &directives);
+ if (error != NSERROR_OK) {
+ if (directives != NULL) {
+ http_directive_list_destroy(directives);
+ }
+ return error;
+ }
+ } else {
+ directives = first;
+ }
+
+ /* Each directive must only appear once */
+ if (check_duplicates(directives) == false) {
+ http_directive_list_destroy(directives);
+ return NSERROR_NOT_FOUND;
+ }
+
+ /* max-age is required */
+ error = http_directive_list_find_item(directives,
+ corestring_lwc_max_age, &max_age_str);
+ if (error != NSERROR_OK || max_age_str == NULL) {
+ http_directive_list_destroy(directives);
+ return NSERROR_NOT_FOUND;
+ }
+
+ error = parse_max_age(max_age_str, &max_age);
+ if (error != NSERROR_OK) {
+ lwc_string_unref(max_age_str);
+ http_directive_list_destroy(directives);
+ return NSERROR_NOT_FOUND;
+ }
+ lwc_string_unref(max_age_str);
+
+ /* includeSubDomains is optional and valueless */
+ error = http_directive_list_find_item(directives,
+ corestring_lwc_includesubdomains, &isd_str);
+ if (error != NSERROR_OK && error != NSERROR_NOT_FOUND) {
+ http_directive_list_destroy(directives);
+ return NSERROR_NOT_FOUND;
+ } else if (error == NSERROR_OK) {
+ if (isd_str != NULL) {
+ /* Present, but not valueless: invalid */
+ lwc_string_unref(isd_str);
+ http_directive_list_destroy(directives);
+ return NSERROR_NOT_FOUND;
+ }
+ include_sub_domains = true;
+ }
+ http_directive_list_destroy(directives);
+
+ sts = malloc(sizeof(*sts));
+ if (sts == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ sts->max_age = max_age;
+ sts->include_sub_domains = include_sub_domains;
+
+ *result = sts;
+
+ return NSERROR_OK;
+}
+
+/* See strict-transport-security.h for documentation */
+void http_strict_transport_security_destroy(
+ http_strict_transport_security *victim)
+{
+ free(victim);
+}
+
+/* See strict-transport-security.h for documentation */
+uint32_t http_strict_transport_security_max_age(
+ http_strict_transport_security *sts)
+{
+ return sts->max_age;
+}
+
+/* See strict-transport-security.h for documentation */
+bool http_strict_transport_security_include_subdomains(
+ http_strict_transport_security *sts)
+{
+ return sts->include_sub_domains;
+}
+
diff --git a/utils/http/strict-transport-security.h b/utils/http/strict-transport-security.h
new file mode 100644
index 0000000..4e52419
--- /dev/null
+++ b/utils/http/strict-transport-security.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018 John-Mark Bell <jmb(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_UTILS_HTTP_STRICT_TRANSPORT_SECURITY_H_
+#define NETSURF_UTILS_HTTP_STRICT_TRANSPORT_SECURITY_H_
+
+#include <libwapcaplet/libwapcaplet.h>
+
+typedef struct http_strict_transport_security http_strict_transport_security;
+
+/**
+ * Parse an HTTP Strict-Transport-Security header value
+ *
+ * \param header_value Header value to parse
+ * \param result Pointer to location to receive result
+ * \return NSERROR_OK on success,
+ * NSERROR_NOMEM on memory exhaustion,
+ * appropriate error otherwise
+ */
+nserror http_parse_strict_transport_security(const char *header_value,
+ http_strict_transport_security **result);
+
+/**
+ * Destroy a strict transport security object
+ *
+ * \param victim Object to destroy
+ */
+void http_strict_transport_security_destroy(
+ http_strict_transport_security *victim);
+
+/**
+ * Get the value of a strict transport security's max-age
+ *
+ * \param sts Object to inspect
+ * \return Max age, in delta-seconds
+ */
+uint32_t http_strict_transport_security_max_age(
+ http_strict_transport_security *sts);
+
+/**
+ * Get the value of a strict transport security's includeSubDomains flag
+ *
+ * \param sts Object to inspect
+ * \return Whether subdomains should be included
+ */
+bool http_strict_transport_security_include_subdomains(
+ http_strict_transport_security *sts);
+
+#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=475a0cd5d251fe81337...
commit 475a0cd5d251fe813373b0ffa4ad85033f0b6dc3
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
LLCache: correct typos/grammar/etc.
diff --git a/content/llcache.c b/content/llcache.c
index 0c6f3a9..58803ea 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -86,7 +86,7 @@ struct llcache_handle {
typedef struct llcache_object_user {
llcache_handle *handle; /**< Handle data for client */
- bool iterator_target; /**< This is the an iterator target */
+ bool iterator_target; /**< This is the iterator target */
bool queued_for_delete; /**< This user is queued for deletion */
struct llcache_object_user *prev; /**< Previous in list */
@@ -126,7 +126,7 @@ typedef enum {
} llcache_validate;
/**
- * cache control value for invalid age.
+ * Cache control value for invalid age.
*/
#define INVALID_AGE -1
@@ -150,7 +150,7 @@ typedef struct {
char *value; /**< Header value */
} llcache_header;
-/** Current status of objects data */
+/** Current status of an object's data */
typedef enum {
LLCACHE_STATE_RAM = 0, /**< source data is stored in RAM only */
LLCACHE_STATE_DISC, /**< source data is stored on disc */
@@ -191,7 +191,7 @@ struct llcache_object {
/* Instrumentation. These elements are strictly for information
* to improve the cache performance and to provide performance
- * metrics. The values are non-authorative and must not be used to
+ * metrics. The values are non-authoritative and must not be used to
* determine object lifetime etc.
*/
time_t last_used; /**< time the last user was removed from the object */
@@ -791,7 +791,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
/**
* (Re)fetch an object
*
- * sets up headers and attempts to start an actual fetch from the
+ * Sets up headers and attempts to start an actual fetch from the
* fetchers system updating the llcache object with the new fetch on
* successful start.
*
@@ -1165,14 +1165,14 @@ llcache_object_remove_from_list(llcache_object *object, llcache_object **list)
/**
* Retrieve source data for an object from persistent store if necessary.
*
- * If an objects source data has been placed in the persistent store
- * and the in memory copy released this will attempt to retrieve the
- * source data.
+ * If an object's source data has been placed in the persistent store
+ * and there is no in-memory copy, then attempt to retrieve the source
+ * data.
*
* \param object the object to operate on.
* \return appropriate error code.
*/
-static nserror llcache_persist_retrieve(llcache_object *object)
+static nserror llcache_retrieve_persisted_data(llcache_object *object)
{
/* ensure the source data is present if necessary */
if ((object->source_data != NULL) ||
@@ -1191,7 +1191,7 @@ static nserror llcache_persist_retrieve(llcache_object *object)
}
/**
- * Generate a serialised version of an objects metadata
+ * Generate a serialised version of an object's metadata
*
* The metadata includes object headers.
*
@@ -1335,7 +1335,7 @@ operror:
}
/**
- * Deserialisation of an objects metadata.
+ * Deserialisation of an object's metadata.
*
* Attempt to retrieve and deserialise the metadata for an object from
* the backing store.
@@ -1361,7 +1361,7 @@ llcache_process_metadata(llcache_object *object)
size_t source_length;
time_t request_time;
- time_t reponse_time;
+ time_t response_time;
time_t completion_time;
size_t num_headers;
size_t hloop;
@@ -1412,7 +1412,7 @@ llcache_process_metadata(llcache_object *object)
nsurl_unref(metadataurl);
- /* metadata line 2 is the objects length */
+ /* metadata line 2 is the object's length */
line = 2;
ln += lnsize + 1;
lnsize = strlen(ln);
@@ -1438,7 +1438,7 @@ llcache_process_metadata(llcache_object *object)
ln += lnsize + 1;
lnsize = strlen(ln);
- res = nsc_snptimet(ln, lnsize, &reponse_time);
+ res = nsc_snptimet(ln, lnsize, &response_time);
if (res != NSERROR_OK)
goto format_error;
@@ -1485,7 +1485,7 @@ llcache_process_metadata(llcache_object *object)
object->source_alloc = metadatalen;
object->cache.req_time = request_time;
- object->cache.res_time = reponse_time;
+ object->cache.res_time = response_time;
object->cache.fin_time = completion_time;
/* object stored in backing store */
@@ -1514,7 +1514,7 @@ format_error:
* cache else appropriate error code.
*/
static nserror
-llcache_object_fetch_persistant(llcache_object *object,
+llcache_object_fetch_persistent(llcache_object *object,
uint32_t flags,
nsurl *referer,
const llcache_post_data *post,
@@ -1604,7 +1604,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
return error;
/* attempt to retrieve object from persistent store */
- error = llcache_object_fetch_persistant(obj, flags, referer, post, redirect_count);
+ error = llcache_object_fetch_persistent(obj, flags, referer, post, redirect_count);
if (error == NSERROR_OK) {
NSLOG(llcache, DEBUG, "retrieved object from persistent store");
@@ -1631,7 +1631,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
*/
/* ensure the source data is present */
- error = llcache_persist_retrieve(newest);
+ error = llcache_retrieve_persisted_data(newest);
if (error == NSERROR_OK) {
/* source data was successfully retrieved from
* persistent store
@@ -1658,7 +1658,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
/* Found a candidate object but it needs freshness validation */
/* ensure the source data is present */
- error = llcache_persist_retrieve(newest);
+ error = llcache_retrieve_persisted_data(newest);
if (error == NSERROR_OK) {
/* Create a new object */
@@ -3444,8 +3444,8 @@ static void llcache_catch_up_all_users(void *ignored)
llcache_object *object;
/* Assume after this we'll be all caught up. If any user of a handle
- * defers then we'll end up set not caught up and we'll
- * reschedule at that point via llcache_users_not_caught_up()
+ * defers then we'll invalidate all_caught_up and reschedule via
+ * llcache_users_not_caught_up()
*/
llcache->all_caught_up = true;
-----------------------------------------------------------------------
--
NetSurf Browser
5 years, 7 months
libcss: branch tlsa/jmb/mq updated. release/0.7.0-34-gf1d2dfe
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/f1d2dfec8a0ffe90171c54...
...commit http://git.netsurf-browser.org/libcss.git/commit/f1d2dfec8a0ffe90171c547b...
...tree http://git.netsurf-browser.org/libcss.git/tree/f1d2dfec8a0ffe90171c547b91...
The branch, tlsa/jmb/mq has been updated
via f1d2dfec8a0ffe90171c547b912613388538f273 (commit)
from 84d60a9fd17a4192924fd11040a310737e850438 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=f1d2dfec8a0ffe90171c...
commit f1d2dfec8a0ffe90171c547b912613388538f273
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: Implement parsing <general-enclosed>.
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 719e129..172b618 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -433,14 +433,118 @@ static css_error mq_parse_media_feature(css_language *c,
return CSS_OK;
}
+/*
+ * Consume any value
+ *
+ * CSS Syntax Module Level 3: 8.2
+ */
+static css_error mq_parse_consume_any_value(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ const char *until_char)
+{
+ const css_token *token;
+ css_error error;
+
+ while (true) {
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_INVALID_STRING:
+ return CSS_INVALID;
+
+ case CSS_TOKEN_CHAR:
+ if (until_char != NULL) {
+ if (tokenIsChar(token, *until_char)) {
+ /* Found matching close bracket */
+ return CSS_OK;
+
+ } else if (tokenIsChar(token, ')') ||
+ tokenIsChar(token, ']') ||
+ tokenIsChar(token, '}')) {
+ /* Non-matching close bracket */
+ return CSS_INVALID;
+ } else if (tokenIsChar(token, ';')) {
+ /* Non-top-level semi-colon */
+ return CSS_INVALID;
+ }
+ }
+ if (tokenIsChar(token, '(')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, ")");
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '[')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, "]");
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '{')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, "}");
+ if (error != CSS_OK) {
+ return error;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return CSS_OK;
+}
+
static css_error mq_parse_general_enclosed(css_language *c,
const parserutils_vector *vector, int *ctx)
{
+ const css_token *token;
+ css_error error;
+
/* <general-enclosed> = [ <function-token> <any-value> ) ]
* | ( <ident> <any-value> )
*/
- /* TODO: implement */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_FUNCTION:
+ error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (!tokenIsChar(token, ')')) {
+ return CSS_INVALID;
+ }
+ break;
+
+ case CSS_TOKEN_IDENT:
+ error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ if (error != CSS_OK) {
+ return error;
+ }
+ break;
+
+ default:
+ return CSS_INVALID;
+ }
return CSS_OK;
}
-----------------------------------------------------------------------
Summary of changes:
src/parse/mq.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 719e129..172b618 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -433,14 +433,118 @@ static css_error mq_parse_media_feature(css_language *c,
return CSS_OK;
}
+/*
+ * Consume any value
+ *
+ * CSS Syntax Module Level 3: 8.2
+ */
+static css_error mq_parse_consume_any_value(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ const char *until_char)
+{
+ const css_token *token;
+ css_error error;
+
+ while (true) {
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_INVALID_STRING:
+ return CSS_INVALID;
+
+ case CSS_TOKEN_CHAR:
+ if (until_char != NULL) {
+ if (tokenIsChar(token, *until_char)) {
+ /* Found matching close bracket */
+ return CSS_OK;
+
+ } else if (tokenIsChar(token, ')') ||
+ tokenIsChar(token, ']') ||
+ tokenIsChar(token, '}')) {
+ /* Non-matching close bracket */
+ return CSS_INVALID;
+ } else if (tokenIsChar(token, ';')) {
+ /* Non-top-level semi-colon */
+ return CSS_INVALID;
+ }
+ }
+ if (tokenIsChar(token, '(')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, ")");
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '[')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, "]");
+ if (error != CSS_OK) {
+ return error;
+ }
+ } else if (tokenIsChar(token, '{')) {
+ /* Need to consume until matching bracket. */
+ error = mq_parse_consume_any_value(
+ c, vector, ctx, "}");
+ if (error != CSS_OK) {
+ return error;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return CSS_OK;
+}
+
static css_error mq_parse_general_enclosed(css_language *c,
const parserutils_vector *vector, int *ctx)
{
+ const css_token *token;
+ css_error error;
+
/* <general-enclosed> = [ <function-token> <any-value> ) ]
* | ( <ident> <any-value> )
*/
- /* TODO: implement */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ return CSS_INVALID;
+ }
+
+ switch (token->type) {
+ case CSS_TOKEN_FUNCTION:
+ error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (!tokenIsChar(token, ')')) {
+ return CSS_INVALID;
+ }
+ break;
+
+ case CSS_TOKEN_IDENT:
+ error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+ if (error != CSS_OK) {
+ return error;
+ }
+ break;
+
+ default:
+ return CSS_INVALID;
+ }
return CSS_OK;
}
--
Cascading Style Sheets library
5 years, 7 months
libcss: branch tlsa/jmb/mq updated. release/0.7.0-33-g84d60a9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/84d60a9fd17a4192924fd1...
...commit http://git.netsurf-browser.org/libcss.git/commit/84d60a9fd17a4192924fd110...
...tree http://git.netsurf-browser.org/libcss.git/tree/84d60a9fd17a4192924fd11040...
The branch, tlsa/jmb/mq has been updated
via 84d60a9fd17a4192924fd11040a310737e850438 (commit)
via 7ac9d1d20ea5be2326651108083a23277523157b (commit)
via 8e1278e738f5736ea083dadaecd8603a3048c558 (commit)
via bcfdbe274523b9cb51a1d92dee26dbadcecc23f4 (commit)
via c97512eb3dcf012f0a0088075f45d51cb4acf59d (commit)
from 3f241d9b69f4283c7c98b43fc4b1eeba1fc158c7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=84d60a9fd17a4192924f...
commit 84d60a9fd17a4192924fd11040a310737e850438
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: Squash invalid use of unused variable warning.
error: ‘last’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
diff --git a/src/parse/mq.c b/src/parse/mq.c
index f587f8d..719e129 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -780,7 +780,7 @@ css_error css__mq_parse_media_list(css_language *c,
const parserutils_vector *vector, int *ctx,
css_mq_query **media)
{
- css_mq_query *result = NULL, *last;
+ css_mq_query *result = NULL, *last = NULL;
const css_token *token;
css_error error;
@@ -804,6 +804,7 @@ css_error css__mq_parse_media_list(css_language *c,
if (result == NULL) {
result = last = query;
} else {
+ assert(last != NULL);
last->next = query;
last = query;
}
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=7ac9d1d20ea5be232665...
commit 7ac9d1d20ea5be2326651108083a23277523157b
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: Add forward declaration of mq_parse_condition.
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 932d6aa..f587f8d 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -17,6 +17,10 @@
#include "parse/properties/utils.h"
#include "utils/utils.h"
+static css_error mq_parse_condition(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ bool permit_or, css_mq_cond **cond);
+
static css_error mq_parse_ratio(
const parserutils_vector *vector, int *ctx,
const css_token *numerator, css_fixed *ratio)
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=8e1278e738f5736ea083...
commit 8e1278e738f5736ea083dadaecd8603a3048c558
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: mq_parse_ratio doesn't need language object.
diff --git a/src/parse/mq.c b/src/parse/mq.c
index f99d5b0..932d6aa 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -17,7 +17,7 @@
#include "parse/properties/utils.h"
#include "utils/utils.h"
-static css_error mq_parse_ratio(css_language *c,
+static css_error mq_parse_ratio(
const parserutils_vector *vector, int *ctx,
const css_token *numerator, css_fixed *ratio)
{
@@ -166,7 +166,7 @@ static css_error mq_parse_range(css_language *c,
if (name_or_value->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
return error;
}
@@ -213,7 +213,7 @@ static css_error mq_parse_range(css_language *c,
if (value_or_name->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
return error;
}
@@ -260,7 +260,7 @@ static css_error mq_parse_range(css_language *c,
if (value_or_name->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio2);
+ error = mq_parse_ratio(vector, ctx, token, &ratio2);
if (error != CSS_OK) {
return error;
}
@@ -381,7 +381,7 @@ static css_error mq_parse_media_feature(css_language *c,
/* ratio */
css_fixed ratio;
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
free(result);
return error;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=bcfdbe274523b9cb51a1...
commit bcfdbe274523b9cb51a1d92dee26dbadcecc23f4
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Media Queries: Minor fixes.
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 8bdd7a0..f99d5b0 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -82,8 +82,9 @@ static css_error mq_populate_value(css_mq_value *value,
const char *data = lwc_string_data(token->idata);
uint32_t unit = UNIT_PX;
size_t consumed;
+ css_error error;
- value->type == CSS_MQ_VALUE_TYPE_DIM;
+ value->type = CSS_MQ_VALUE_TYPE_DIM;
value->data.dim.len = css__number_from_lwc_string(
token->idata, false, &consumed);
error = css__parse_unit_keyword(data + consumed, len - consumed,
@@ -91,7 +92,7 @@ static css_error mq_populate_value(css_mq_value *value,
if (error != CSS_OK) {
return error;
}
- value->data.dim.unit = temp_unit;
+ value->data.dim.unit = unit;
} else if (token->type == CSS_TOKEN_IDENT) {
value->type = CSS_MQ_VALUE_TYPE_IDENT;
value->data.ident = lwc_string_ref(token->idata);
@@ -447,7 +448,7 @@ static css_error mq_parse_media_in_parens(css_language *c,
const css_token *token;
bool match;
int old_ctx;
- cond_or_feature *result = NULL;
+ css_mq_cond_or_feature *result = NULL;
css_error error = CSS_OK;
/* <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>
@@ -609,7 +610,7 @@ static css_error mq_parse_condition(css_language *c,
result->parts->parts = parts;
result->parts->nparts++;
- consumeWhitespace(vector, token);
+ consumeWhitespace(vector, ctx);
token = parserutils_vector_peek(vector, *ctx);
if (token != NULL && tokenIsChar(token, ')') == false &&
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=c97512eb3dcf012f0a00...
commit c97512eb3dcf012f0a0088075f45d51cb4acf59d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Strings: Add 'infinite'.
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index dc32ce9..3c9401b 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -442,6 +442,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "and", SLEN("and") },
{ "or", SLEN("or") },
{ "only", SLEN("only") },
+ { "infinite", SLEN("infinite") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 0d5d0be..24b681b 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -101,7 +101,7 @@ enum {
AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
- COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY,
+ COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY, INFINITE,
/* Named colours */
FIRST_COLOUR,
-----------------------------------------------------------------------
Summary of changes:
src/parse/mq.c | 26 ++++++++++++++++----------
src/parse/propstrings.c | 1 +
src/parse/propstrings.h | 2 +-
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/parse/mq.c b/src/parse/mq.c
index 8bdd7a0..719e129 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -17,7 +17,11 @@
#include "parse/properties/utils.h"
#include "utils/utils.h"
-static css_error mq_parse_ratio(css_language *c,
+static css_error mq_parse_condition(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ bool permit_or, css_mq_cond **cond);
+
+static css_error mq_parse_ratio(
const parserutils_vector *vector, int *ctx,
const css_token *numerator, css_fixed *ratio)
{
@@ -82,8 +86,9 @@ static css_error mq_populate_value(css_mq_value *value,
const char *data = lwc_string_data(token->idata);
uint32_t unit = UNIT_PX;
size_t consumed;
+ css_error error;
- value->type == CSS_MQ_VALUE_TYPE_DIM;
+ value->type = CSS_MQ_VALUE_TYPE_DIM;
value->data.dim.len = css__number_from_lwc_string(
token->idata, false, &consumed);
error = css__parse_unit_keyword(data + consumed, len - consumed,
@@ -91,7 +96,7 @@ static css_error mq_populate_value(css_mq_value *value,
if (error != CSS_OK) {
return error;
}
- value->data.dim.unit = temp_unit;
+ value->data.dim.unit = unit;
} else if (token->type == CSS_TOKEN_IDENT) {
value->type = CSS_MQ_VALUE_TYPE_IDENT;
value->data.ident = lwc_string_ref(token->idata);
@@ -165,7 +170,7 @@ static css_error mq_parse_range(css_language *c,
if (name_or_value->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
return error;
}
@@ -212,7 +217,7 @@ static css_error mq_parse_range(css_language *c,
if (value_or_name->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
return error;
}
@@ -259,7 +264,7 @@ static css_error mq_parse_range(css_language *c,
if (value_or_name->type == CSS_TOKEN_NUMBER &&
tokenIsChar(parserutils_vector_peek(vector, *ctx), '/')) {
/* ratio */
- error = mq_parse_ratio(c, vector, ctx, token, &ratio2);
+ error = mq_parse_ratio(vector, ctx, token, &ratio2);
if (error != CSS_OK) {
return error;
}
@@ -380,7 +385,7 @@ static css_error mq_parse_media_feature(css_language *c,
/* ratio */
css_fixed ratio;
- error = mq_parse_ratio(c, vector, ctx, token, &ratio);
+ error = mq_parse_ratio(vector, ctx, token, &ratio);
if (error != CSS_OK) {
free(result);
return error;
@@ -447,7 +452,7 @@ static css_error mq_parse_media_in_parens(css_language *c,
const css_token *token;
bool match;
int old_ctx;
- cond_or_feature *result = NULL;
+ css_mq_cond_or_feature *result = NULL;
css_error error = CSS_OK;
/* <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>
@@ -609,7 +614,7 @@ static css_error mq_parse_condition(css_language *c,
result->parts->parts = parts;
result->parts->nparts++;
- consumeWhitespace(vector, token);
+ consumeWhitespace(vector, ctx);
token = parserutils_vector_peek(vector, *ctx);
if (token != NULL && tokenIsChar(token, ')') == false &&
@@ -775,7 +780,7 @@ css_error css__mq_parse_media_list(css_language *c,
const parserutils_vector *vector, int *ctx,
css_mq_query **media)
{
- css_mq_query *result = NULL, *last;
+ css_mq_query *result = NULL, *last = NULL;
const css_token *token;
css_error error;
@@ -799,6 +804,7 @@ css_error css__mq_parse_media_list(css_language *c,
if (result == NULL) {
result = last = query;
} else {
+ assert(last != NULL);
last->next = query;
last = query;
}
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index dc32ce9..3c9401b 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -442,6 +442,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "and", SLEN("and") },
{ "or", SLEN("or") },
{ "only", SLEN("only") },
+ { "infinite", SLEN("infinite") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 0d5d0be..24b681b 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -101,7 +101,7 @@ enum {
AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
- COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY,
+ COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY, INFINITE,
/* Named colours */
FIRST_COLOUR,
--
Cascading Style Sheets library
5 years, 7 months
netsurf: branch master updated. release/3.7-69-g42f5bb6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/42f5bb6182f90313eceb3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/42f5bb6182f90313eceb3c1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/42f5bb6182f90313eceb3c1b6...
The branch, master has been updated
via 42f5bb6182f90313eceb3c1b60bfd4792bbba3d5 (commit)
from 5e52c6a233bd597f1d370287239f4122044ec849 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=42f5bb6182f90313ece...
commit 42f5bb6182f90313eceb3c1b60bfd4792bbba3d5
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Framebuffer: Squash switch fall through warning.
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 8bbaedc..1e27daf 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -951,7 +951,8 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
browser_window_key_press(gw->bw, NS_KEY_REDO);
break;
}
- /* Z or Y pressed but not undo or redo; Fall through */
+ /* Z or Y pressed but not undo or redo; */
+ /* Fall through */
default:
ucs4 = fbtk_keycode_to_ucs4(cbi->event->value.keycode,
-----------------------------------------------------------------------
Summary of changes:
frontends/framebuffer/gui.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 8bbaedc..1e27daf 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -951,7 +951,8 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
browser_window_key_press(gw->bw, NS_KEY_REDO);
break;
}
- /* Z or Y pressed but not undo or redo; Fall through */
+ /* Z or Y pressed but not undo or redo; */
+ /* Fall through */
default:
ucs4 = fbtk_keycode_to_ucs4(cbi->event->value.keycode,
--
NetSurf Browser
5 years, 7 months
netsurf: branch master updated. release/3.7-68-g5e52c6a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5e52c6a233bd597f1d370...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5e52c6a233bd597f1d37028...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5e52c6a233bd597f1d3702872...
The branch, master has been updated
via 5e52c6a233bd597f1d370287239f4122044ec849 (commit)
from 256ffca9a75974f46e44cbd375937bce5575dad2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5e52c6a233bd597f1d3...
commit 5e52c6a233bd597f1d370287239f4122044ec849
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Add missing dependency between font_internal and the generated fonts
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 760e85b..323ca6c 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -130,10 +130,12 @@ define convert_font
S_FONTS += $(2)
-$(2): $(1) $(TOOLROOT)/convert_font
+$(2) $(3): $(1) $(TOOLROOT)/convert_font
$(VQ)echo " FONT: $(1) ($(4))"
$(Q)$(TOOLROOT)/convert_font -H $(3) $(1) $(2)
+frontends/framebuffer/font_internal.c: $(3)
+
endef
S_FONTS :=
-----------------------------------------------------------------------
Summary of changes:
frontends/framebuffer/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 760e85b..323ca6c 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -130,10 +130,12 @@ define convert_font
S_FONTS += $(2)
-$(2): $(1) $(TOOLROOT)/convert_font
+$(2) $(3): $(1) $(TOOLROOT)/convert_font
$(VQ)echo " FONT: $(1) ($(4))"
$(Q)$(TOOLROOT)/convert_font -H $(3) $(1) $(2)
+frontends/framebuffer/font_internal.c: $(3)
+
endef
S_FONTS :=
--
NetSurf Browser
5 years, 7 months