aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-29 10:57:01 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-29 10:57:01 +0200
commitb40e60db39f0b187774cfd2e0fe1b503f9bf1a54 (patch)
tree38fd49db9aad6e7dcca05a24b1add0cf7e96c243 /lib
parent3963fdd2bc0a8b1a3665b2dfdab574cf53bf071d (diff)
Fixing http_encode(): BitlBee now calls setlocale() (for nickname
transliteration to work), which changes the behaviour of isalpha() (turns out it's not a simple macro). For HTTP-encoding, this sucks, especially when doing OAuth (which is very picky about the way HTTP encoding is done). This should fix problems some people were seeing with posting Twitter messages containing accents.
Diffstat (limited to 'lib')
-rw-r--r--lib/misc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/misc.c b/lib/misc.c
index 47c1ac90..26d22ae0 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -304,14 +304,18 @@ void http_encode( char *s )
for( i = j = 0; t[i]; i ++, j ++ )
{
- if( !isalnum( t[i] ) && !strchr( "._-~", t[i] ) )
+ /* Warning: isalnum() is locale-aware, so don't use it here! */
+ if( ( t[i] >= 'A' && t[i] <= 'Z' ) ||
+ ( t[i] >= 'a' && t[i] <= 'z' ) ||
+ ( t[i] >= '0' && t[i] <= '9' ) ||
+ strchr( "._-~", t[i] ) )
{
- sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
- j += 2;
+ s[j] = t[i];
}
else
{
- s[j] = t[i];
+ sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
+ j += 2;
}
}
s[j] = 0;