Changeset 4b17a6c
- Timestamp:
- Apr 9, 2009, 12:32:56 PM (15 years ago)
- 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:
- 9d12aa5
- Parents:
- e6c59ba
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
util.c
rf34dd65 r4b17a6c 725 725 } 726 726 } 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. 729 730 */ 730 char * owl_ get_iso_8859_1_if_possible(char *in)731 char * owl_validate_utf8(char *in) 731 732 { 732 733 char *out; 733 734 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 { 742 737 out = owl_strdup(""); 743 738 } -
zwrite.c
r823671c r4b17a6c 42 42 break; 43 43 } 44 z->class=owl_ get_iso_8859_1_if_possible(myargv[1]);44 z->class=owl_validate_utf8(myargv[1]); 45 45 myargv+=2; 46 46 myargc-=2; … … 50 50 break; 51 51 } 52 z->inst=owl_ get_iso_8859_1_if_possible(myargv[1]);52 z->inst=owl_validate_utf8(myargv[1]); 53 53 myargv+=2; 54 54 myargc-=2; … … 58 58 break; 59 59 } 60 z->realm=owl_ get_iso_8859_1_if_possible(myargv[1]);60 z->realm=owl_validate_utf8(myargv[1]); 61 61 myargv+=2; 62 62 myargc-=2; … … 66 66 break; 67 67 } 68 z->zsig=owl_ get_iso_8859_1_if_possible(myargv[1]);68 z->zsig=owl_validate_utf8(myargv[1]); 69 69 myargv+=2; 70 70 myargc-=2; … … 74 74 break; 75 75 } 76 z->opcode=owl_ get_iso_8859_1_if_possible(myargv[1]);76 z->opcode=owl_validate_utf8(myargv[1]); 77 77 myargv+=2; 78 78 myargc-=2; … … 91 91 myargv++; 92 92 myargc--; 93 z->message =owl_get_iso_8859_1_if_possible("");93 z->message = owl_strdup(""); 94 94 while (myargc) { 95 95 z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5); … … 111 111 } else { 112 112 /* 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])); 114 114 myargv++; 115 115 myargc--; … … 152 152 153 153 if (zsigowlvar && *zsigowlvar) { 154 z->zsig=owl_ get_iso_8859_1_if_possible(zsigowlvar);154 z->zsig=owl_validate_utf8(zsigowlvar); 155 155 } else if (zsigproc && *zsigproc) { 156 156 FILE *file; … … 167 167 if (!file) { 168 168 if (zsigzvar && *zsigzvar) { 169 z->zsig=owl_ get_iso_8859_1_if_possible(zsigzvar);169 z->zsig=owl_validate_utf8(zsigzvar); 170 170 } 171 171 } else { … … 181 181 } 182 182 } else if (zsigzvar) { 183 z->zsig=owl_ get_iso_8859_1_if_possible(zsigzvar);183 z->zsig=owl_validate_utf8(zsigzvar); 184 184 } 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); 186 186 ptr=strchr(z->zsig, ','); 187 187 if (ptr) { … … 240 240 tmp = NULL; 241 241 } 242 tmp = owl_ get_iso_8859_1_if_possible(msg);242 tmp = owl_validate_utf8(msg); 243 243 z->message=owl_sprintf("%s\n%s", toline, tmp); 244 244 owl_free(toline); 245 245 } else { 246 z->message=owl_ get_iso_8859_1_if_possible(msg);246 z->message=owl_validate_utf8(msg); 247 247 } 248 248 if (tmp) owl_free(tmp); … … 321 321 { 322 322 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); 324 324 } 325 325
Note: See TracChangeset
for help on using the changeset viewer.