Package: mupdf
Version: 1.21.1+ds1-1

Recent versions of mupdf have a bug in the handling of '<' and '>' characters in SVG output. For example, with the following file:

https://gnu.support/files/tmp/2023-01-05/FR%20205.pdf

mutool draw -o foo.svg <file> 1

produces an invalid SVG file, with several occurrences of '<use data-text="<" ... />'.

The function svg_dev_data_text should use the same logic as svg_dev_text_span for these characters. Patch attached.
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index dff27789..db634076 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -568,7 +568,7 @@ svg_dev_data_text(fz_context *ctx, fz_buffer *out, int c)
 			fz_append_string(ctx, out, "&amp;");
 		else if (c == '"')
 			fz_append_string(ctx, out, "&quot;");
-		else if (c >= 32 && c < 127)
+		else if (c >= 32 && c < 127 && c != '<' && c != '>')
 			fz_append_byte(ctx, out, c);
 		else
 			fz_append_printf(ctx, out, "&#x%04x;", c);

Reply via email to