[gtk/wip/otte/for-master: 24/24] css: Don't throw warnings on broken URL in image css




commit 6624fba2526a366ed125f1a978fbe17ce36dad8f
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 26 17:02:56 2021 +0200

    css: Don't throw warnings on broken URL in image css
    
    This was broken in 0886ade182f1a958024202d5c20248d57fcdb053
    
    A new reftest has been included. We need a reftest instead of a
    CSS parser test, because the error only becomes visible when
    compute()ing the actual image.
    
    Fixes #4373

 gtk/gtkcssimageurl.c                           | 4 ++++
 testsuite/reftests/css-image-broken-url.css    | 4 ++++
 testsuite/reftests/css-image-broken-url.ref.ui | 8 ++++++++
 testsuite/reftests/css-image-broken-url.ui     | 9 +++++++++
 testsuite/reftests/meson.build                 | 3 +++
 5 files changed, 28 insertions(+)
---
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index 8c9253744b..daed055afb 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -220,6 +220,10 @@ gtk_css_image_url_parse (GtkCssImage  *image,
   g_free (url);
   g_free (scheme);
 
+  /* errors have been emitted above for this case */
+  if (self->file == NULL)
+    return FALSE;
+
   return TRUE;
 }
 
diff --git a/testsuite/reftests/css-image-broken-url.css b/testsuite/reftests/css-image-broken-url.css
new file mode 100644
index 0000000000..d7035a5e6d
--- /dev/null
+++ b/testsuite/reftests/css-image-broken-url.css
@@ -0,0 +1,4 @@
+#test {
+  /* The url should fail as early as possible */
+  background-image: url('data::::');
+}
diff --git a/testsuite/reftests/css-image-broken-url.ref.ui b/testsuite/reftests/css-image-broken-url.ref.ui
new file mode 100644
index 0000000000..3c0e77e927
--- /dev/null
+++ b/testsuite/reftests/css-image-broken-url.ref.ui
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow" id="window1">
+    <property name="width_request">10</property>
+    <property name="height_request">10</property>
+    <property name="decorated">0</property>
+  </object>
+</interface>
diff --git a/testsuite/reftests/css-image-broken-url.ui b/testsuite/reftests/css-image-broken-url.ui
new file mode 100644
index 0000000000..286c35fe09
--- /dev/null
+++ b/testsuite/reftests/css-image-broken-url.ui
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow" id="window1">
+    <property name="width_request">10</property>
+    <property name="height_request">10</property>
+    <property name="decorated">0</property>
+    <property name="name">test</property>
+  </object>
+</interface>
diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build
index 8e1b8bd501..b033760ed7 100644
--- a/testsuite/reftests/meson.build
+++ b/testsuite/reftests/meson.build
@@ -221,6 +221,9 @@ testdata = [
   'css-image-aspect-ratio.css',
   'css-image-aspect-ratio.ui',
   'css-image-aspect-ratio.ref.ui',
+  'css-image-broken-url.css',
+  'css-image-broken-url.ref.ui',
+  'css-image-broken-url.ui',
   'css-image-color-aspect-ratio.css',
   'css-image-color-aspect-ratio.ui',
   'css-image-color-aspect-ratio.ref.ui',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]