diff options
author | corvid <corvid@lavabit.com> | 2012-12-04 19:56:03 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2012-12-04 19:56:03 +0000 |
commit | 7ecf0501bb1439c77255ad0808abbe3141cf4bc7 (patch) | |
tree | 5a8506b93c03ccb8870e8a17c99606c579a0a439 /src/form.cc | |
parent | 818df41dbd73abb0001d5dcdabaf75b10597c0a9 (diff) |
form submission: try to transliterate data
Unilaterally changing user data is consistently a bad idea, but when browser
users aren't given any idea what they are permitted to type, it's better than
leaving out the chars, or replacing with '?' or whatever.
Diffstat (limited to 'src/form.cc')
-rw-r--r-- | src/form.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/form.cc b/src/form.cc index 96fdbe27..cf608cfc 100644 --- a/src/form.cc +++ b/src/form.cc @@ -1056,7 +1056,18 @@ Dstr *DilloHtmlForm::buildQueryData(DilloHtmlInput *active_submit) iconv_t char_encoder = (iconv_t) -1; if (submit_charset && dStrAsciiCasecmp(submit_charset, "UTF-8")) { - char_encoder = iconv_open(submit_charset, "UTF-8"); + /* Some iconv implementations, given "//TRANSLIT", will do their best to + * transliterate the string. Under the circumstances, doing so is likely + * for the best. + */ + char *translit = dStrconcat(submit_charset, "//TRANSLIT", NULL); + + char_encoder = iconv_open(translit, "UTF-8"); + dFree(translit); + + if (char_encoder == (iconv_t) -1) + char_encoder = iconv_open(submit_charset, "UTF-8"); + if (char_encoder == (iconv_t) -1) { MSG_WARN("Cannot convert to character encoding '%s'\n", submit_charset); |