[librsvg: 11/17] Move the code to validate an XML processing instruction for a stylesheet to the XML module




commit 581633351620af5da49f51cdba339b9c5b4fc9d0
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Aug 29 20:08:18 2022 -0500

    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>

 src/document.rs | 10 ----------
 src/xml/mod.rs  | 12 +++++++++++-
 2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/document.rs b/src/document.rs
index 7f159fe43..7f5ee8164 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 b06e3fb34..ad00710df 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!(


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