Skip to content

Commit

Permalink
fixup! Middleware to decode encoding and charset
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Mar 27, 2016
1 parent be1113b commit f539fce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/valum/valum-decode.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> @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) {
Expand Down

0 comments on commit f539fce

Please sign in to comment.