aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-07-11 06:06:56 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-07-11 06:06:56 +0800
commite39d94c5ef8d88c726a29f2cfa994a6a0d90be5a (patch)
treef310c84a954e8e3ab7ddf65f894245fe5cda4e63 /camel/camel-mime-utils.c
parent456227c7b4997debde1b8a89273e3eb0c3ec90bc (diff)
downloadgsoc2013-evolution-e39d94c5ef8d88c726a29f2cfa994a6a0d90be5a.tar.gz
gsoc2013-evolution-e39d94c5ef8d88c726a29f2cfa994a6a0d90be5a.tar.zst
gsoc2013-evolution-e39d94c5ef8d88c726a29f2cfa994a6a0d90be5a.zip
New function to parse an HTML meta-tag.
2001-07-10 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (html_meta_param_list_decode): New function to parse an HTML meta-tag. * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): If the Content-Type did not contain a charset parameter and it's also a text/html part, we have 1 last place to look - in the META html tags. *sigh* * camel-mime-message.c (camel_mime_message_get_source): s/gint/unsigned since that's what it should be. svn path=/trunk/; revision=10976
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r--camel/camel-mime-utils.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 10730a4301..bf166faa4b 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1626,18 +1626,18 @@ header_encode_phrase (const unsigned char *in)
/* these are all internal parser functions */
static char *
-decode_token(const char **in)
+decode_token (const char **in)
{
const char *inptr = *in;
const char *start;
-
- header_decode_lwsp(&inptr);
+
+ header_decode_lwsp (&inptr);
start = inptr;
- while (is_ttoken(*inptr))
+ while (is_ttoken (*inptr))
inptr++;
- if (inptr>start) {
+ if (inptr > start) {
*in = inptr;
- return g_strndup(start, inptr-start);
+ return g_strndup (start, inptr - start);
} else {
return NULL;
}
@@ -2719,6 +2719,58 @@ header_param_list_decode(const char *in)
return header_decode_param_list(&in);
}
+struct _header_param *
+html_meta_param_list_decode (const char *in, int inlen)
+{
+ struct _header_param *params = NULL, *last = NULL;
+ const char *inptr, *inend;
+
+ if (in == NULL)
+ return NULL;
+
+ inptr = in;
+ inend = inptr + inlen;
+
+ if (*inptr != '<')
+ return NULL;
+
+ if (!g_strncasecmp (inptr, "<meta", 5))
+ inptr += 5;
+ else
+ return NULL;
+
+ header_decode_lwsp (&inptr);
+
+ while (inptr < inend && *inptr != '>') {
+ char *name = NULL, *value = NULL;
+ struct _header_param *param;
+
+ name = decode_token (&inptr);
+ header_decode_lwsp (&inptr);
+ if (*inptr != '=') {
+ g_free (name);
+ break;
+ }
+
+ value = header_decode_value (&inptr);
+ header_decode_lwsp (&inptr);
+
+ param = g_malloc (sizeof (struct _header_param));
+ param->next = NULL;
+ param->name = name;
+ param->value = value;
+
+ if (last) {
+ last->next = param;
+ last = param;
+ } else {
+ last = params = param;
+ }
+ }
+
+ return params;
+}
+
/* FIXME: I wrote this in a quick & dirty fasion - it may not be 100% correct */
static char *
header_encode_param (const unsigned char *in, gboolean *encoded)