From 67ffde03ba201311730b022456161ced9ec18fc6 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Mon, 30 Jun 2008 17:32:07 +0000 Subject: [PATCH] Bug 983: Give precedence to HTTP Content-Type header over HTML meta tag The Content-Type from the HTTP response header has precedence over the Content-Type from a meta http-equiv tag. http://www.w3.org/International/tutorials/tutorial-char-enc/en/all.html This fixes bug 983. (cherry picked from commit 6cf099a08777296c2064b1e1370ed3d26973fce1) Conflicts: NEWS --- AUTHORS | 3 +++ NEWS | 2 ++ src/document/renderer.c | 13 +++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3da58d99..1900cc63 100644 --- a/AUTHORS +++ b/AUTHORS @@ -269,6 +269,9 @@ Jon Shapcott John Tab browsing initial patch +Johannes Stezenbach + Precedence of HTTP vs. HTTP meta tag when setting Content-Type + Johannes Zellner Minor misc hacking diff --git a/NEWS b/NEWS index 76ced334..1b6741a6 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ To be released as 0.12pre6 or 0.12rc1. * major bug 764: Correctly initialize options on big-endian 64-bit systems. +* bug 983: Give preference to the Content-Type specified in the HTTP + header over that specified via the HTML meta tag. Bugs that should be removed from NEWS before the 0.12.0 release: diff --git a/src/document/renderer.c b/src/document/renderer.c index 55c175c4..8dcd5d25 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -591,17 +591,14 @@ get_convert_table(unsigned char *head, int to_cp, while (cp_index == -1) { unsigned char *ct_charset; - unsigned char *meta; + /* scan_http_equiv() appends the meta http-equiv directives to + * the protocol header before this function is called, but the + * HTTP Content-Type header has precedence, so the HTTP header + * will be used if it exists and the meta header is only used + * as a fallback. See bug 983. */ unsigned char *a = parse_header(part, "Content-Type", &part); if (!a) break; - /* Content type info from document meta header. - * scan_http_equiv() appends the meta stuff to the protocol header before - * this function is called. Last Content-Type header field is used. */ - - while ((meta = parse_header(part, "Content-Type", &part))) { - mem_free_set(&a, meta); - } parse_header_param(a, "charset", &ct_charset); if (ct_charset) {