Changeset eea72a1 for util.c


Ignore:
Timestamp:
Sep 12, 2009, 7:37:37 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5118b32
Parents:
2340422
Message:
owl_new_sv: Escape non-utf8 strings before erroring with them.

Sending known non-utf8 text back into other code is just a bad
plan. In particular, multiline error messages become admin messages,
which results in their bodies getting sent to perl, which calls
owl_new_sv, and we would recurse infinitely.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r36486be reea72a1  
    758758  return 0;
    759759}
     760
     761char *owl_escape_highbit(const char *str)
     762{
     763  GString *out = g_string_new("");
     764  unsigned char c;
     765  while((c = (*str++))) {
     766    if(c == '\\') {
     767      g_string_append(out, "\\\\");
     768    } else if(c & 0x80) {
     769      g_string_append_printf(out, "\\x%02x", (int)c);
     770    } else {
     771      g_string_append_c(out, c);
     772    }
     773  }
     774  return g_string_free(out, 0);
     775}
Note: See TracChangeset for help on using the changeset viewer.