summaryrefslogtreecommitdiffstats
path: root/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-01 00:00:32 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-01 00:00:32 +0200
commitca9627e70852f6b2e835660df870fe3ab405882d (patch)
tree0a008b1d5b16fa0679a195ed7b5662c7891f591c /app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff
downloaddarklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.gz
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.bz2
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.xz
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.zip
Initial import
Diffstat (limited to 'app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff')
-rw-r--r--app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff47
1 files changed, 47 insertions, 0 deletions
diff --git a/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff b/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff
new file mode 100644
index 0000000..1626f25
--- /dev/null
+++ b/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff
@@ -0,0 +1,47 @@
+--- src/modules/translate-generic-service.c.orig Mon Apr 11 23:08:47 2005
++++ src/modules/translate-generic-service.c Mon Apr 11 23:15:54 2005
+@@ -484,7 +484,7 @@
+
+ if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code))
+ {
+- const char *charset = NULL;
++ char *charset = NULL;
+
+ if (flags & TRANSFER_CONVERT)
+ {
+@@ -493,14 +493,31 @@
+ content_type = translate_generic_service_get_header(message, &info, "Content-Type");
+ if (content_type)
+ {
+- charset = translate_ascii_strcasestr(content_type, "charset=");
+- if (charset)
+- charset += 8;
++ const char *tmp;
++
++ tmp = translate_ascii_strcasestr(content_type, "charset=");
++ if (tmp)
++ {
++ int len;
++
++ tmp += 8;
++ if (*tmp == '\'' || *tmp == '"')
++ tmp++;
++
++ len = strlen(tmp);
++ if (len > 0 && (tmp[len - 1] == '\'' || tmp[len - 1] == '"'))
++ len--;
++
++ charset = g_strndup(tmp, len);
++ }
+ }
+ }
+
+ if (charset)
+- response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err);
++ {
++ response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err);
++ g_free(charset);
++ }
+ else
+ {
+ if ((flags & TRANSFER_CONVERT) && ! g_utf8_validate(message->response.body, message->response.length, NULL))