DEF_DLL_FN (void, g_type_init, (void));
# endif
DEF_DLL_FN (void, g_object_unref, (gpointer));
-DEF_DLL_FN (void, g_clear_error, (GError **));
+DEF_DLL_FN (void, g_error_free, (GError *));
static bool
init_svg_functions (void)
LOAD_DLL_FN (gobject, g_type_init);
# endif
LOAD_DLL_FN (gobject, g_object_unref);
- LOAD_DLL_FN (glib, g_clear_error);
+ LOAD_DLL_FN (glib, g_error_free);
return 1;
}
# undef gdk_pixbuf_get_pixels
# undef gdk_pixbuf_get_rowstride
# undef gdk_pixbuf_get_width
-# undef g_clear_error
+# undef g_error_free
# undef g_object_unref
# undef g_type_init
# if LIBRSVG_CHECK_VERSION (2, 52, 1)
# define gdk_pixbuf_get_pixels fn_gdk_pixbuf_get_pixels
# define gdk_pixbuf_get_rowstride fn_gdk_pixbuf_get_rowstride
# define gdk_pixbuf_get_width fn_gdk_pixbuf_get_width
-# define g_clear_error fn_g_clear_error
+# define g_error_free fn_g_error_free
# define g_object_unref fn_g_object_unref
# if ! GLIB_CHECK_VERSION (2, 36, 0)
# define g_type_init fn_g_type_init
if (! check_image_size (f, width, height))
{
image_size_error ();
- goto rsvg_error;
+ goto done_error;
}
/* We are now done with the unmodified data. */
image_put_x_image (f, img, ximg, 0);
}
+ eassume (err == NULL);
return true;
rsvg_error:
+ if (err == NULL)
+ image_error ("Error parsing SVG image");
+ else
+ {
+ image_error ("Error parsing SVG image: %s",
+ call2 (Qstring_trim_right, build_string (err->message),
+ Qnil));
+ g_error_free (err);
+ }
+
+ done_error:
if (rsvg_handle)
g_object_unref (rsvg_handle);
if (wrapped_contents)
if (css && !STRINGP (lcss))
xfree (css);
#endif
- image_error ("Error parsing SVG image: %s",
- /* The -1 removes an extra newline. */
- make_string (err->message, strlen (err->message) - 1));
- g_clear_error (&err);
return false;
}
imagemagick_render_type = 0;
#endif
+ DEFSYM (Qstring_trim_right, "string-trim-right");
}
(image-tests-make-load-image-test 'xbm)
(image-tests-make-load-image-test 'xpm)
+(ert-deftest image-tests-load-image/svg-too-big ()
+ (with-temp-buffer
+ (let* ((max-image-size 0)
+ (messages-buffer-name (buffer-name (current-buffer)))
+ (img (cdr (assq 'svg image-tests--images)))
+ (file (if (listp img)
+ (plist-get (cdr img) :file)
+ img)))
+ (save-excursion (find-file file))
+ (should (string-match-p "invalid image size" (buffer-string)))
+ ;; no annoying newlines
+ (should-not (string-match-p "^[ \t\n\r]+$" (buffer-string)))
+ ;; no annoying double error reporting
+ (should-not (string-match-p "error parsing" (buffer-string))))))
+
(ert-deftest image-tests-load-image/svg-invalid ()
(with-temp-buffer
(let ((messages-buffer-name (buffer-name (current-buffer))))
:type svg)))
(redisplay))
;; librsvg error: "... Start tag expected, '<' not found [3 times]"
- (should (string-match "[Ee]rror.+Start tag expected" (buffer-string))))))
+ (should (string-match-p "[Ee]rror.+Start tag expected" (buffer-string)))
+ ;; no annoying newlines
+ (should-not (string-match-p "^[ \t\n\r]+$" (buffer-string))))))
\f
;;;; image-test-size