diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+v0.3	2010-11-02	special characters
+
+Fixes a bug where broken SVG was generated when label names
+contained XML-special characters.
+
+Source code statistics: 484 lines, 2888 words, 17261 chars.
+
+
 v0.2	2010-07-30	leaner and meaner
 
 Memory usage and speed have both been improved, in part by
diff --git a/THANKS b/THANKS
new file mode 100644
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,1 @@
+Ian Lynagh (label text XML escaping bugfix patch)
diff --git a/hp2pretty.cabal b/hp2pretty.cabal
--- a/hp2pretty.cabal
+++ b/hp2pretty.cabal
@@ -1,5 +1,5 @@
 Name:                hp2pretty
-Version:             0.2
+Version:             0.3
 Synopsis:            generate pretty graphs from heap profiles
 Description:         hp2pretty is a rewrite of hp2ps, implemented in Haskell, with
                      the aims of being maintainable, with more flexible output, and
@@ -17,7 +17,7 @@
 Copyright:           (C) 2010  Claude Heiland-Allen
 Category:            Development
 Build-type:          Simple
-Extra-source-files:  NEWS README
+Extra-source-files:  NEWS README THANKS
 Cabal-version:       >=1.6
 
 Executable hp2pretty
@@ -42,4 +42,4 @@
 Source-repository this
   type:                git
   location:            git://gitorious.org/hp2pretty/hp2pretty.git
-  tag:                 v0.2
+  tag:                 v0.3
diff --git a/src/SVG.hs b/src/SVG.hs
--- a/src/SVG.hs
+++ b/src/SVG.hs
@@ -2,6 +2,7 @@
 module SVG (svg) where
 
 import Data.ByteString.Char8 (ByteString, pack)
+import qualified Data.ByteString.Char8 as BS
 import Numeric (showHex, showFFloat)
 
 import Graphics (Graphics(Graphics), Point, Size, Angle, FontSize, Anchor(..), StrokeWidth, Opacity, RGB(..))
@@ -26,7 +27,15 @@
       showAnchor Start = "start"
       showAnchor Middle = "middle"
       showAnchor End = "end"
-  in  ["<text "] ++ coords ++ [" font-size='", showF s, "' text-anchor='", showAnchor a, "'>"] ++ inner ++ ["</text>\n"]
+  in  ["<text "] ++ coords ++ [" font-size='", showF s, "' text-anchor='", showAnchor a, "'>"] ++ map escape inner ++ ["</text>\n"]
+
+escape :: ByteString -> ByteString
+escape = BS.concatMap escapeChar
+  where
+    escapeChar '<' = "&lt;"
+    escapeChar '>' = "&gt;"
+    escapeChar '&' = "&amp;"
+    escapeChar c   = BS.singleton c
 
 rect :: Point -> Size -> [ByteString]
 rect (x,y) (w,h) = ["<rect x='", showF x, "' y='", showF y, "' width='" , showF w , "' height='" , showF h , "' />\n"]
