Skip to content

Commit

Permalink
Make buf_append_urlencoded() more conservative about non-ASCII chars.
Browse files Browse the repository at this point in the history
Windows isalnum() will return TRUE for odd things depending on the code page.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jul 28, 2014
1 parent bbcaa4d commit ea25ecf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions http.c
Expand Up @@ -49,10 +49,12 @@ struct oc_text_buf *buf_alloc(void)
void buf_append_urlencoded(struct oc_text_buf *buf, char *str)
{
while (str && *str) {
if (isalnum((int)(unsigned char)*str))
unsigned char c = *str;
if (c < 0x80 && isalnum((int)(c)))
buf_append_bytes(buf, str, 1);
else
buf_append(buf, "%%%02x", (unsigned char)*str);
buf_append(buf, "%%%02x", c);

str++;
}
}
Expand Down

0 comments on commit ea25ecf

Please sign in to comment.