comparison 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
comparison
equal deleted inserted replaced
13:de04a3fc6b72 14:6b2a44da71b0
1 #include <ctype.h>
1 #include <string.h> 2 #include <string.h>
2 3
3 #include <openssl/bio.h> 4 #include <openssl/bio.h>
4 #include <openssl/evp.h> 5 #include <openssl/evp.h>
5 #include <openssl/buffer.h> 6 #include <openssl/buffer.h>
131 uw_buffer_init(BUF_MAX, r, BUF_INIT); 132 uw_buffer_init(BUF_MAX, r, BUF_INIT);
132 return r; 133 return r;
133 } 134 }
134 135
135 static void postify(uw_OpenidFfi_inputs buf, uw_Basis_string s) { 136 static void postify(uw_OpenidFfi_inputs buf, uw_Basis_string s) {
137 char hex[4];
138
136 for (; *s; ++s) { 139 for (; *s; ++s) {
137 switch (*s) { 140 if (isalnum(*s))
141 uw_buffer_append(buf, s, 1);
142 else {
143 sprintf(hex, "%%%02X", (unsigned char)*s);
144 uw_buffer_append(buf, hex, 3);
145 }
146
147 /*switch (*s) {
138 case '=': 148 case '=':
139 uw_buffer_append(buf, "%3D", 3); 149 uw_buffer_append(buf, "%3D", 3);
140 break; 150 break;
141 case '&': 151 case '&':
142 uw_buffer_append(buf, "%26", 3); 152 uw_buffer_append(buf, "%26", 3);
143 break; 153 break;
154 case '%':
155 uw_buffer_append(buf, "%25", 3);
156 break;
144 default: 157 default:
145 uw_buffer_append(buf, s, 1); 158 uw_buffer_append(buf, s, 1);
146 } 159 }*/
147 } 160 }
148 } 161 }
149 162
150 uw_unit uw_OpenidFfi_addInput(uw_context ctx, uw_OpenidFfi_inputs buf, uw_Basis_string key, uw_Basis_string value) { 163 uw_unit uw_OpenidFfi_addInput(uw_context ctx, uw_OpenidFfi_inputs buf, uw_Basis_string key, uw_Basis_string value) {
151 if (uw_buffer_used(buf) > 0) 164 if (uw_buffer_used(buf) > 0)
152 uw_buffer_append(buf, "&", 1); 165 uw_buffer_append(buf, "&", 1);
153 166
154 postify(buf, key); 167 uw_buffer_append(buf, key, strlen(key));
155 uw_buffer_append(buf, "=", 1); 168 uw_buffer_append(buf, "=", 1);
156 postify(buf, value); 169 postify(buf, value);
157 170
158 return uw_unit_v; 171 return uw_unit_v;
159 } 172 }