diff src/c/openid.c @ 14:6b2a44da71b0

Change postify to satisfy more OPs; add untested invalidate_handle support
author Adam Chlipala <adam@chlipala.net>
date Sun, 02 Jan 2011 10:33:07 -0500
parents de04a3fc6b72
children ee97bc0e08fa
line wrap: on
line diff
--- a/src/c/openid.c	Sun Jan 02 10:11:38 2011 -0500
+++ b/src/c/openid.c	Sun Jan 02 10:33:07 2011 -0500
@@ -1,3 +1,4 @@
+#include <ctype.h>
 #include <string.h>
 
 #include <openssl/bio.h>
@@ -133,17 +134,29 @@
 }
 
 static void postify(uw_OpenidFfi_inputs buf, uw_Basis_string s) {
+  char hex[4];
+
   for (; *s; ++s) {
-    switch (*s) {
+    if (isalnum(*s))
+      uw_buffer_append(buf, s, 1);
+    else {
+      sprintf(hex, "%%%02X", (unsigned char)*s);
+      uw_buffer_append(buf, hex, 3);
+    }
+
+    /*switch (*s) {
     case '=':
       uw_buffer_append(buf, "%3D", 3);
       break;
     case '&':
       uw_buffer_append(buf, "%26", 3);
       break;
+    case '%':
+      uw_buffer_append(buf, "%25", 3);
+      break;
     default:
       uw_buffer_append(buf, s, 1);
-    }
+    }*/
   }
 }
 
@@ -151,7 +164,7 @@
   if (uw_buffer_used(buf) > 0)
     uw_buffer_append(buf, "&", 1);
 
-  postify(buf, key);
+  uw_buffer_append(buf, key, strlen(key));
   uw_buffer_append(buf, "=", 1);
   postify(buf, value);