diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2014-06-09 18:46:47 +0200 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2014-06-09 18:46:47 +0200 |
commit | 550c97499c8f4aefea58716f9eab660bcf4e92ad (patch) | |
tree | 7ff3ab6094d82cf233ac83dcefd06c1c41931a8e | |
parent | 07f95487b11c165fcb150a5e09213ff32a8309e5 (diff) |
Remove non-printable characters from error output
This is already in poppler
-rw-r--r-- | ALL_DIFF | 43 |
1 files changed, 0 insertions, 43 deletions
@@ -22640,49 +22640,6 @@ diff -uNrp xpdf-3.03/xpdf/Error.cc xpdf-3.04/xpdf/Error.cc +void CDECL error(ErrorCategory category, GFileOffset pos, + const char *msg, ...) { va_list args; -- GString *s; -+ GString *s, *sanitized; -+ char c; -+ int i; - - // NB: this can be called before the globalParams object is created - if (!errorCbk && globalParams && globalParams->getErrQuiet()) { -@@ -52,17 +55,32 @@ void CDECL error(ErrorCategory category, - va_start(args, msg); - s = GString::formatv(msg, args); - va_end(args); -+ -+ // remove non-printable characters, just in case they might cause -+ // problems for the terminal program -+ sanitized = new GString(); -+ for (i = 0; i < s->getLength(); ++i) { -+ c = s->getChar(i); -+ if (c >= 0x20 && c <= 0x7e) { -+ sanitized->append(c); -+ } else { -+ sanitized->appendf("<{0:02x}>", c & 0xff); -+ } -+ } -+ - if (errorCbk) { -- (*errorCbk)(errorCbkData, category, pos, s->getCString()); -+ (*errorCbk)(errorCbkData, category, (int)pos, sanitized->getCString()); - } else { - if (pos >= 0) { - fprintf(stderr, "%s (%d): %s\n", -- errorCategoryNames[category], pos, s->getCString()); -+ errorCategoryNames[category], (int)pos, sanitized->getCString()); - } else { - fprintf(stderr, "%s: %s\n", -- errorCategoryNames[category], s->getCString()); -+ errorCategoryNames[category], sanitized->getCString()); - } - fflush(stderr); - } -+ - delete s; -+ delete sanitized; - } diff -uNrp xpdf-3.03/xpdf/Error.h xpdf-3.04/xpdf/Error.h --- xpdf-3.03/xpdf/Error.h 2011-08-15 23:08:53.000000000 +0200 +++ xpdf-3.04/xpdf/Error.h 2014-05-28 20:50:50.000000000 +0200 |