Updating branch refs/heads/master to 0b9e9c2802362545d08c7711797d0ac5b3f74504 (commit) from 323c82a406ba1fa2e183d8797bd494b2dbab3976 (commit)
commit 0b9e9c2802362545d08c7711797d0ac5b3f74504 Author: Christian Dywan <christ...@twotoasts.de> Date: Mon May 31 20:19:52 2010 +0200 Parse subject and content type of source properly postler/postler-content.vala | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/postler/postler-content.vala b/postler/postler-content.vala index 3e45d03..b45ed93 100644 --- a/postler/postler-content.vala +++ b/postler/postler-content.vala @@ -157,15 +157,25 @@ public class Postler.Content : WebKit.WebView { if (view_source) { body = new GLib.StringBuilder (); while ((line = stream.read_line (null, null)) != null) { - if (line.has_prefix ("Content-Type:")) - content_type = line.substring (14, line.length - 14); + parts = line.split (":", 2); + if (parts != null && parts[0] != null) { + string field = parts[0].down (); + if (field == "content-type") + content_type = parts[1].strip (); + else if (field == "subject") + subject = parse_encoded (parts[1], out charset); + } body.append (line + "\n"); } - parts = content_type.split ("; charset="); - if (parts != null && parts[0] != null && parts[1] != null) { - mime_type = parts[0]; - charset = parts[1]; + if (content_type != null) { + parts = content_type.split_set ("; "); + foreach (var part in parts) { + if (part.has_prefix ("charset=")) + charset = part.substring (8, part.length - 8); + else if (part != "" && !part.contains ("=")) + mime_type = part.down (); + } } if (charset == null) charset = default_charset; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits