]> spindle.queued.net Git - midori/commitdiff
Handle multi-line -moz-document blocks
authorPaweł Forysiuk <tuxator@o2.pl>
Fri, 5 Nov 2010 22:26:34 +0000 (23:26 +0100)
committerChristian Dywan <christian@twotoasts.de>
Fri, 5 Nov 2010 22:27:57 +0000 (23:27 +0100)
extensions/addons.c

index 229051f227d06b0e770baeaf0ed39679f2acd150..3ec1048e4b085cf4cdf232592f1def97edfc080d 100644 (file)
@@ -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);
     }