summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-10 00:34:47 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-10 00:34:47 +0000
commitf176cde7832c53ab23db12a231d17da0b1a80fbc (patch)
tree7be78c8b8f7421e7bca4c60f9038fb80b4336ceb
parent60b5029e03cef1867bf21c21e0be10bd308e97b8 (diff)
Core: in tools.c, enhance urlencoded_to_string to support semu-colon separator
-rw-r--r--lasso/xml/tools.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index c0bcaa9a..9d72e8f9 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -813,22 +813,34 @@ urlencoded_to_strings(const char *str)
char *st, *st2;
char **result;
+ /* count components */
st = (char*)str;
- while (strchr(st, '&')) {
- st = strchr(st, '&')+1;
+ while (*st) {
+ if (*st == '&' || *st == ';')
+ n++;
n++;
+ st++;
}
- result = g_malloc(sizeof(char*)*(n+1));
+ /* allocate result array */
+ result = g_new0(char*, n+1);
result[n] = NULL;
- st = (char*)str;
- for (i=0; i<n; i++) {
- st2 = strchr(st, '&');
- st2 = st2 ? st2 : st+strlen(st);
- result[i] = xmlURIUnescapeString(st, st2-st, NULL);
- st = st2 + 1;
+ /* tokenize */
+ st = st2 = (char*)str;
+ i = 0;
+ while(1) {
+ if (*st == '&' || *st == ';' || *st == '\0') {
+ ptrdiff_t len = st - st2;
+ result[i] = xmlURIUnescapeString(st2, len, NULL);
+ i++;
+ st2 = st + 1;
+ if (*st == '\0')
+ break;
+ }
+ st++;
}
+
return result;
}