summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2022-08-29 20:08:18 -0500
committerFederico Mena Quintero <federico@gnome.org>2022-08-29 20:08:18 -0500
commit581633351620af5da49f51cdba339b9c5b4fc9d0 (patch)
tree928ca5cdbfe2455cca609ed9b698b6856717efde
parenta3469ef1a941b9d4f028ac5958e25b1974be4a85 (diff)
downloadlibrsvg-581633351620af5da49f51cdba339b9c5b4fc9d0.tar.gz
Move the code to validate an XML processing instruction for a stylesheet to the XML module
It has no business in document.rs. Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/738>
-rw-r--r--src/document.rs10
-rw-r--r--src/xml/mod.rs12
2 files changed, 11 insertions, 11 deletions
diff --git a/src/document.rs b/src/document.rs
index 7f159fe4..7f5ee816 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -544,18 +544,8 @@ impl DocumentBuilder {
pub fn append_stylesheet_from_xml_processing_instruction(
&mut self,
- alternate: Option<String>,
- type_: Option<String>,
href: &str,
) -> Result<(), LoadingError> {
- if type_.as_deref() != Some("text/css")
- || (alternate.is_some() && alternate.as_deref() != Some("no"))
- {
- return Err(LoadingError::Other(String::from(
- "invalid parameters in XML processing instruction for stylesheet",
- )));
- }
-
let aurl = self
.load_options
.url_resolver
diff --git a/src/xml/mod.rs b/src/xml/mod.rs
index b06e3fb3..ad00710d 100644
--- a/src/xml/mod.rs
+++ b/src/xml/mod.rs
@@ -270,6 +270,16 @@ impl XmlState {
let session = inner.document_builder.as_mut().unwrap().session().clone();
+ if type_.as_deref() != Some("text/css")
+ || (alternate.is_some() && alternate.as_deref() != Some("no"))
+ {
+ rsvg_log!(
+ session,
+ "invalid parameters in XML processing instruction for stylesheet",
+ );
+ return;
+ }
+
if let Some(href) = href {
// FIXME: https://www.w3.org/TR/xml-stylesheet/ does not seem to specify
// what to do if the stylesheet cannot be loaded, so here we ignore the error.
@@ -277,7 +287,7 @@ impl XmlState {
.document_builder
.as_mut()
.unwrap()
- .append_stylesheet_from_xml_processing_instruction(alternate, type_, &href)
+ .append_stylesheet_from_xml_processing_instruction(&href)
.is_err()
{
rsvg_log!(