From 96a276219aa1bb8209fb256ccebdc4b41e14d2d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Forysiuk?= Date: Fri, 5 Nov 2010 23:26:34 +0100 Subject: [PATCH] Handle multi-line -moz-document blocks --- extensions/addons.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/addons.c b/extensions/addons.c index 229051f2..3ec1048e 100644 --- a/extensions/addons.c +++ b/extensions/addons.c @@ -794,6 +794,7 @@ css_metadata_from_file (const gchar* filename, GIOChannel* channel; gchar* line; gchar* rest_of_line; + gboolean line_has_meta; if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) return FALSE; @@ -802,21 +803,26 @@ css_metadata_from_file (const gchar* filename, if (!channel) return FALSE; + line_has_meta = FALSE; while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { - if (g_str_has_prefix (line, "@-moz-document")) + if (g_str_has_prefix (line, "@-moz-document") || line_has_meta) { /* FIXME: We merely look for includes. We should honor blocks. */ if (includes) { gchar** parts; guint i; - rest_of_line = g_strdup (line + strlen ("@-moz-document")); + if (g_str_has_prefix (line, "@-moz-document")) + rest_of_line = g_strdup (line + strlen ("@-moz-document")); + else + rest_of_line = g_strdup (line); + rest_of_line = g_strstrip (rest_of_line); parts = g_strsplit (rest_of_line, " ", 0); i = 0; - while (parts[i]) + while (parts[i] && (*parts[i] != '\0' && *parts[i] != '{')) { gchar* value = NULL; if (g_str_has_prefix (parts[i], "url-prefix(")) @@ -830,6 +836,7 @@ css_metadata_from_file (const gchar* filename, guint begin, end; gchar* domain; + line_has_meta = TRUE; begin = value[0] == '"' || value[0] == '\'' ? 1 : 0; end = 1; while (value[end] != '\0' && value[end] != ')') @@ -850,6 +857,7 @@ css_metadata_from_file (const gchar* filename, } g_strfreev (parts); } + line_has_meta = g_str_has_suffix (rest_of_line, "{") ? FALSE : TRUE; } g_free (line); } -- 2.39.5