From 48b26587c1d7244489d34aedfa5f27203713b416 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Tue, 31 May 2011 20:09:13 +0200 Subject: [PATCH] Prevent truncate when the extension is unknown. --- cmd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd.c b/cmd.c index f4e9c09..30923bb 100644 --- a/cmd.c +++ b/cmd.c @@ -245,6 +245,7 @@ cmd_select_format(struct http_client *client, struct cmd *cmd, const char *ext; int ext_len = -1; unsigned int i; + int found = 0; /* did we match it to a predefined format? */ /* those are the available reply formats */ struct reply_format { @@ -294,6 +295,7 @@ cmd_select_format(struct http_client *client, struct cmd *cmd, cmd->mime_free = 0; *f_format = funs[i].f; + found = 1; } } @@ -304,7 +306,12 @@ cmd_select_format(struct http_client *client, struct cmd *cmd, cmd->mime_free = 1; } - return uri_len - ext_len - 1; + if(found) { + return uri_len - ext_len - 1; + } else { + /* no matching format, use default output with the full argument, extension included. */ + return uri_len; + } } int