From f539fcea3176c5c4e291bdb9973acb52b97e9321 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 27 Mar 2016 18:26:55 -0400 Subject: [PATCH] fixup! Middleware to decode encoding and charset --- src/valum/valum-decode.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/valum/valum-decode.vala b/src/valum/valum-decode.vala index 6446a5fa6..53c4098f0 100644 --- a/src/valum/valum-decode.vala +++ b/src/valum/valum-decode.vala @@ -94,11 +94,14 @@ namespace Valum { * @param destination destination charset * @param flags flags that determine decoding behaviours */ - public HandlerCallback decode_charset (string destination = "UTF-8", DecodeFlags flags = DecodeFlags.NONE) { + public HandlerCallback decode_charset (string destination, DecodeFlags flags = DecodeFlags.NONE) { return (req, res, next) => { HashTable @params; var content_type = req.headers.get_content_type (out @params); - var from = @params["charset"] ?? (content_type.down ().has_prefix ("text/") ? "iso-8859-1" : null); + if (content_type == null) + return next (); + + var from = @params["charset"] ?? (content_type.down ().has_prefix ("text/") ? "iso-8859-1" : null); // no charset to decode (or default) if (from == null) {