Changeset f9f065a


Ignore:
Timestamp:
Apr 12, 2009, 12:42:44 AM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
32620ac
Parents:
56e4869 (diff), 4b17a6c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'always-send-utf8'
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • util.c

    rf34dd65 r4b17a6c  
    725725  }
    726726}
    727 /* Attempts to convert 'in' to ISO-8859-1. Returns that if possible,
    728    else returns UTF-8.
     727/*
     728 * Validate 'in' as UTF-8, and either return a copy of it, or an empty
     729 * string if it is invalid utf-8.
    729730 */
    730 char * owl_get_iso_8859_1_if_possible(char *in)
     731char * owl_validate_utf8(char *in)
    731732{
    732733  char *out;
    733734  if (g_utf8_validate(in, -1, NULL)) {
    734     out = g_convert(in, -1,
    735                     "ISO-8859-1", "UTF-8",
    736                     NULL, NULL, NULL);
    737     if (!out) {
    738       out = owl_strdup(in);
    739     }
    740   }
    741   else {
     735    out = owl_strdup(in);
     736  } else {
    742737    out = owl_strdup("");
    743738  }
  • zwrite.c

    r823671c r4b17a6c  
    4242        break;
    4343      }
    44       z->class=owl_get_iso_8859_1_if_possible(myargv[1]);
     44      z->class=owl_validate_utf8(myargv[1]);
    4545      myargv+=2;
    4646      myargc-=2;
     
    5050        break;
    5151      }
    52       z->inst=owl_get_iso_8859_1_if_possible(myargv[1]);
     52      z->inst=owl_validate_utf8(myargv[1]);
    5353      myargv+=2;
    5454      myargc-=2;
     
    5858        break;
    5959      }
    60       z->realm=owl_get_iso_8859_1_if_possible(myargv[1]);
     60      z->realm=owl_validate_utf8(myargv[1]);
    6161      myargv+=2;
    6262      myargc-=2;
     
    6666        break;
    6767      }
    68       z->zsig=owl_get_iso_8859_1_if_possible(myargv[1]);
     68      z->zsig=owl_validate_utf8(myargv[1]);
    6969      myargv+=2;
    7070      myargc-=2;
     
    7474        break;
    7575      }
    76       z->opcode=owl_get_iso_8859_1_if_possible(myargv[1]);
     76      z->opcode=owl_validate_utf8(myargv[1]);
    7777      myargv+=2;
    7878      myargc-=2;
     
    9191      myargv++;
    9292      myargc--;
    93       z->message=owl_get_iso_8859_1_if_possible("");
     93      z->message = owl_strdup("");
    9494      while (myargc) {
    9595        z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
     
    111111    } else {
    112112      /* anything unattached is a recipient */
    113       owl_list_append_element(&(z->recips), owl_get_iso_8859_1_if_possible(myargv[0]));
     113      owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0]));
    114114      myargv++;
    115115      myargc--;
     
    152152
    153153    if (zsigowlvar && *zsigowlvar) {
    154       z->zsig=owl_get_iso_8859_1_if_possible(zsigowlvar);
     154      z->zsig=owl_validate_utf8(zsigowlvar);
    155155    } else if (zsigproc && *zsigproc) {
    156156      FILE *file;
     
    167167      if (!file) {
    168168        if (zsigzvar && *zsigzvar) {
    169           z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
     169          z->zsig=owl_validate_utf8(zsigzvar);
    170170        }
    171171      } else {
     
    181181      }
    182182    } else if (zsigzvar) {
    183       z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
     183      z->zsig=owl_validate_utf8(zsigzvar);
    184184    } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
    185       z->zsig=owl_get_iso_8859_1_if_possible(pw->pw_gecos);
     185      z->zsig=owl_validate_utf8(pw->pw_gecos);
    186186      ptr=strchr(z->zsig, ',');
    187187      if (ptr) {
     
    240240      tmp = NULL;
    241241    }
    242     tmp = owl_get_iso_8859_1_if_possible(msg);
     242    tmp = owl_validate_utf8(msg);
    243243    z->message=owl_sprintf("%s\n%s", toline, tmp);
    244244    owl_free(toline);
    245245  } else {
    246     z->message=owl_get_iso_8859_1_if_possible(msg);
     246    z->message=owl_validate_utf8(msg);
    247247  }
    248248  if (tmp) owl_free(tmp);
     
    321321{
    322322  if (z->opcode) owl_free(z->opcode);
    323   z->opcode=owl_get_iso_8859_1_if_possible(opcode);
     323  z->opcode=owl_validate_utf8(opcode);
    324324}
    325325
Note: See TracChangeset for help on using the changeset viewer.