[librsvg/librsvg-2.50] Extract function to munge a MIME type for gdk-pixbuf
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.50] Extract function to munge a MIME type for gdk-pixbuf
- Date: Fri, 30 Apr 2021 17:54:36 +0000 (UTC)
commit aaf5bfde52ebad27f196d94b11a5faa18d06744d
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 17 12:59:58 2021 -0600
Extract function to munge a MIME type for gdk-pixbuf
rsvg_internals/src/document.rs | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/document.rs b/rsvg_internals/src/document.rs
index b6008501..eaf21d8e 100644
--- a/rsvg_internals/src/document.rs
+++ b/rsvg_internals/src/document.rs
@@ -203,18 +203,7 @@ fn load_image(
return Err(LoadingError::EmptyData);
}
- // See issue #548 - data: URLs without a MIME-type automatically
- // fall back to "text/plain;charset=US-ASCII". Some (old?) versions of
- // Adobe Illustrator generate data: URLs without MIME-type for image
- // data. We'll catch this and fall back to sniffing by unsetting the
- // content_type.
- let unspecified_mime_type = Mime::from_str("text/plain;charset=US-ASCII").unwrap();
-
- let content_type = if mime_type == unspecified_mime_type {
- None
- } else {
- Some(format!("{}/{}", mime_type.type_, mime_type.subtype))
- };
+ let content_type = content_type_for_gdk_pixbuf(&mime_type);
let loader = if let Some(ref content_type) = content_type {
PixbufLoader::new_with_mime_type(content_type)?
@@ -238,6 +227,21 @@ fn load_image(
Ok(surface)
}
+fn content_type_for_gdk_pixbuf(mime_type: &Mime) -> Option<String> {
+ // See issue #548 - data: URLs without a MIME-type automatically
+ // fall back to "text/plain;charset=US-ASCII". Some (old?) versions of
+ // Adobe Illustrator generate data: URLs without MIME-type for image
+ // data. We'll catch this and fall back to sniffing by unsetting the
+ // content_type.
+ let unspecified_mime_type = Mime::from_str("text/plain;charset=US-ASCII").unwrap();
+
+ if *mime_type == unspecified_mime_type {
+ None
+ } else {
+ Some(format!("{}/{}", mime_type.type_, mime_type.subtype))
+ }
+}
+
pub struct AcquiredNode {
stack: Option<Rc<RefCell<NodeStack>>>,
node: Node,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]