]> git.tdb.fi Git - ext/subsurface.git/blobdiff - save-xml.c
We can't save escape characters.
[ext/subsurface.git] / save-xml.c
index cd7bad2bad547e652529a301ab8dba9dee3f55cd..b91e24e8d57bcb97e8ab68299bad8f55d9461696 100644 (file)
@@ -44,6 +44,10 @@ static void show_pressure(FILE *f, pressure_t pressure, const char *pre, const c
  * We're outputting utf8 in xml.
  * We need to quote the characters <, >, &.
  *
+ * Technically I don't think we'd necessarily need to quote the control
+ * characters, but at least libxml2 doesn't like them. It doesn't even
+ * allow them quoted. So we just skip them and replace them with '?'.
+ *
  * Nothing else (and if we ever do this using attributes, we'd need to
  * quote the quotes we use too).
  */
@@ -60,6 +64,11 @@ static void quote(FILE *f, const char *text)
                case 0:
                        escape = NULL;
                        break;
+               case 1 ... 8:
+               case 11: case 12:
+               case 14 ... 31:
+                       escape = "?";
+                       break;
                case '<':
                        escape = "&lt;";
                        break;