[librsvg: 13/32] LoadingError: condense SvgHasNoElements and RootElementIsNotSvg into NoSvgRoot
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/32] LoadingError: condense SvgHasNoElements and RootElementIsNotSvg into NoSvgRoot
- Date: Fri, 4 Dec 2020 21:11:31 +0000 (UTC)
commit fc5d9982887b2ec0e19c56b39547b3089498c84c
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Nov 25 17:16:07 2020 -0600
LoadingError: condense SvgHasNoElements and RootElementIsNotSvg into NoSvgRoot
It turns out that libxml2 doesn't seem to allow documents without a
single element, so the first case may be moot. The code covers both
possibilities with a single variant now.
src/document.rs | 4 ++--
src/error.rs | 10 +++-------
tests/src/bugs.rs | 5 +----
3 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/src/document.rs b/src/document.rs
index 55c8418f..50bed00f 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -506,10 +506,10 @@ impl DocumentBuilder {
Ok(document)
} else {
- Err(LoadingError::RootElementIsNotSvg)
+ Err(LoadingError::NoSvgRoot)
}
}
- _ => Err(LoadingError::SvgHasNoElements),
+ _ => Err(LoadingError::NoSvgRoot),
}
}
}
diff --git a/src/error.rs b/src/error.rs
index a5bd8f37..3805eed3 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -330,11 +330,8 @@ pub enum LoadingError {
// FIXME: only used in load_image()
EmptyData,
- /// There are no SVG elements in the document.
- SvgHasNoElements,
-
- /// The outermost element in the document is not `<svg>`.
- RootElementIsNotSvg,
+ /// There is no `<svg>` root element in the XML.
+ NoSvgRoot,
/// Generally an I/O error, or another error from GIO.
Glib(glib::Error),
@@ -358,8 +355,7 @@ impl fmt::Display for LoadingError {
LoadingError::BadStylesheet => write!(f, "invalid stylesheet"),
LoadingError::BadCss => write!(f, "invalid CSS"),
LoadingError::EmptyData => write!(f, "empty data"),
- LoadingError::SvgHasNoElements => write!(f, "SVG has no elements"),
- LoadingError::RootElementIsNotSvg => write!(f, "root element is not <svg>"),
+ LoadingError::NoSvgRoot => write!(f, "XML does not have <svg> root"),
LoadingError::Glib(ref e) => e.fmt(f),
LoadingError::LimitExceeded(ref s) => write!(f, "limit exceeded: {}", s),
LoadingError::Other(ref s) => write!(f, "{}", s),
diff --git a/tests/src/bugs.rs b/tests/src/bugs.rs
index 6cb024f7..2f45f39b 100644
--- a/tests/src/bugs.rs
+++ b/tests/src/bugs.rs
@@ -11,10 +11,7 @@ use crate::utils::{load_svg, render_document, SurfaceSize};
// https://gitlab.gnome.org/GNOME/librsvg/issues/335
#[test]
fn non_svg_root() {
- assert!(matches!(
- load_svg(b"<x></x>"),
- Err(LoadingError::RootElementIsNotSvg)
- ));
+ assert!(matches!(load_svg(b"<x></x>"), Err(LoadingError::NoSvgRoot)));
}
// https://gitlab.gnome.org/GNOME/librsvg/issues/496
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]