Clone in a terminal:
Commit d305b89
Johan Mattsson - 2014-11-26T08:06:10+00:00
d305b89c30931292b167cc7d030a66a296c51805johan.mattsson.m@gmail.com

Escape characters XML texts

Changed files (3)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex b6ead66..5abb8b6 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -663,15 +663,15 @@ class BirdFontFile : GLib.Object { 			}  			if (t.get_name () == "postscript_name") {-				font.postscript_name = t.get_content ();+				font.postscript_name = XmlParser.parse_escaped_text (t.get_content ()); 			} 			 			if (t.get_name () == "name") {-				font.name = t.get_content ();+				font.name = XmlParser.parse_escaped_text (t.get_content ()); 			}  			if (t.get_name () == "subfamily") {-				font.subfamily = t.get_content ();+				font.subfamily = XmlParser.parse_escaped_text (t.get_content ()); 			}  			if (t.get_name () == "bold") {@@ -683,23 +683,23 @@ class BirdFontFile : GLib.Object { 			} 			 			if (t.get_name () == "full_name") {-				font.full_name = t.get_content ();+				font.full_name = XmlParser.parse_escaped_text (t.get_content ()); 			} 			 			if (t.get_name () == "unique_identifier") {-				font.unique_identifier = t.get_content ();+				font.unique_identifier = XmlParser.parse_escaped_text (t.get_content ()); 			}  			if (t.get_name () == "version") {-				font.version = t.get_content ();+				font.version = XmlParser.parse_escaped_text (t.get_content ()); 			}  			if (t.get_name () == "description") {-				font.description = t.get_content ();+				font.description = XmlParser.parse_escaped_text (t.get_content ()); 			} 			 			if (t.get_name () == "copyright") {-				font.copyright = t.get_content ();+				font.copyright = XmlParser.parse_escaped_text (t.get_content ()); 			}  			if (t.get_name () == "kerning") {@@ -728,7 +728,7 @@ class BirdFontFile : GLib.Object { 		TooltipArea.show_text (""); 		return true; 	}-	+		 	public void parse_images (Tag tag) { 		BackgroundImage? new_img; 		BackgroundImage img;diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 91a3d3e..fe5321b 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -2106,6 +2106,7 @@ public class Glyph : FontDisplay { 		 		return (int) (0xFFFFFFFF & i); 	}+ }  }diff --git a/libbirdxml/Xml.vala b/libbirdxml/Xml.valaindex 497ca9e..6704091 100644--- a/libbirdxml/Xml.vala+++ b/libbirdxml/Xml.vala@@ -202,6 +202,19 @@ public class XmlParser { 		print (message); 		print ("\n"); 	}++	/** Replace escaped character with plain text characters. +	 * &amp; will be replaced with & etc.+	 */+	public static string parse_escaped_text (string s) {+		string t;+		t = s.replace ("&quot;", "\"");+		t = t.replace ("&apos;;", "'");+		t = t.replace ("&lt;", "<");+		t = t.replace ("&gt;", ">");+		t = t.replace ("&amp;", "&");+		return t;+	} 	 	private extern void free (); }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112