diff options
author | Simon Bünzli <zeniko@gmail.com> | 2014-07-18 15:21:09 +0200 |
---|---|---|
committer | Simon Bünzli <zeniko@gmail.com> | 2014-07-18 15:21:09 +0200 |
commit | 1d39d9d10c7fa83bb509e50ab135f5f97c2810eb (patch) | |
tree | 8af5303dff2f7c366fd063ef8ffd237b46428c45 | |
parent | 1e91bb1c4b55060809154ff7ba6f210f74499c4b (diff) | |
download | mupdf-1d39d9d10c7fa83bb509e50ab135f5f97c2810eb.tar.xz |
hex-encode UTF-16 strings when writing PDF
fmt_obj calculates whether a string is better hex-encoded or written
using escapes. Due to a bug, '\0' is considered to be escapable same as
'\n' when instead it would have to be written as '\000'. Since UTF-16
strings tend to consist of many '\0' bytes, their octal encoded form is
much longer than their hex encoded form.
The issue is that the first argument to strchr contains an unintended
trailing '\0' which has to be special-cased first.
-rw-r--r-- | source/pdf/pdf-object.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index 51272dea..1b7a5aa9 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -1672,7 +1672,7 @@ static void fmt_obj(struct fmt *fmt, pdf_obj *obj) int i, c; for (i = 0; i < len; i++) { c = (unsigned char)str[i]; - if (strchr("()\\\n\r\t\b\f", c)) + if (c != 0 && strchr("()\\\n\r\t\b\f", c)) added ++; else if (c < 32 || c >= 127) added += 3; |