[gtk+/parser: 65/79] cssprovider: Add recursion checks for @import
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/parser: 65/79] cssprovider: Add recursion checks for @import
- Date: Fri, 15 Apr 2011 12:42:46 +0000 (UTC)
commit dc8e31d2fafa410946665b79073dadba4d9f3796
Author: Benjamin Otte <otte redhat com>
Date: Tue Apr 12 02:50:25 2011 +0200
cssprovider: Add recursion checks for @import
This is pretty important, because otherwise recursions cause crashes.
And if you accidentally change your theme to one that crashes on load,
all your gonna SEGV and then on reboot, gdm tries to load the theme...
gtk/gtkcssprovider.c | 42 ++++++++++++++++++++++++++++++++++++------
1 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 3a89715..ac8cb1b 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1238,6 +1238,23 @@ gtk_css_scanner_get_base_url (GScanner *scanner)
return priv->base;
}
+static gboolean
+gtk_css_scanner_would_recurse (GScanner *scanner,
+ GFile *file)
+{
+ while (scanner)
+ {
+ GtkCssScannerPrivate *priv = scanner->user_data;
+
+ if (priv->file && g_file_equal (priv->file, file))
+ return TRUE;
+
+ scanner = priv->parent;
+ }
+
+ return FALSE;
+}
+
static void
gtk_css_provider_init (GtkCssProvider *css_provider)
{
@@ -2282,12 +2299,25 @@ parse_rule (GtkCssProvider *css_provider,
return ';';
}
- /* FIXME: Avoid recursive importing */
- gtk_css_provider_load_internal (css_provider,
- scanner,
- actual,
- NULL, 0,
- NULL);
+ if (gtk_css_scanner_would_recurse (scanner, actual))
+ {
+ char *path = g_file_get_path (actual);
+ gtk_css_provider_error (css_provider,
+ scanner,
+ GTK_CSS_PROVIDER_ERROR,
+ GTK_CSS_PROVIDER_ERROR_IMPORT,
+ "Loading '%s' would recurse",
+ path);
+ g_free (path);
+ }
+ else
+ {
+ gtk_css_provider_load_internal (css_provider,
+ scanner,
+ actual,
+ NULL, 0,
+ NULL);
+ }
g_object_unref (actual);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]