Proposed Patches for META-DATA branch.

Michael Zervakis <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Dear all,

    During testing of cvs-20081021 meta-data branch we found two issues:
1. The meta_data_pack() always appends an "&" at the end of the 
resulting string. As a result sms.meta_data always contains an "&" at 
the end, which produces queries like the following:
DEBUG:   Query: 
sms_source=%2B999999999&sms_dest=9999&smsc-id=smsc&sms_command=test&meta_data=%3Fsmpp%3Fmessage_reference%3D192%26

2. When using post-xml sms.meta_data is not urlencoded resulting in an 
unreadable XML file like this <meta-data>?smpp?tag=1&</meta-data>.

Regards,
Mike Zervakis
smsbox.c.patch (text/plain, 344 B)
--- smsbox.c    2008-10-09 19:29:28.000000000 +0300
+++ smsbox_debug.c      2008-11-20 18:26:38.000000000 +0200
@@ -1642,6 +1642,7 @@

         /* meta_data */
         if (octstr_len(msg->sms.meta_data)) {
+               octstr_url_encode(msg->sms.meta_data);
             OCTSTR_APPEND_XML(xml, "meta-data", msg->sms.meta_data);
         }
meta_data.c.patch (text/plain, 844 B)
--- meta_data.c 2008-01-24 18:47:02.000000000 +0200
+++ meta_data_debug.c   2008-11-20 18:19:10.000000000 +0200
@@ -233,10 +233,17 @@
     do {
         octstr_format_append(data, "?%E?", mdata->group);
         l = dict_keys(mdata->values);
+
+        if(l != NULL && (tmp = gwlist_extract_first(l)) != NULL) {
+            octstr_format_append(data, "%E=%E", tmp, dict_get(mdata->values, tmp));
+            octstr_destroy(tmp);
+        }
+
         while(l != NULL && (tmp = gwlist_extract_first(l)) != NULL) {
-            octstr_format_append(data, "%E=%E&", tmp, dict_get(mdata->values, tmp));
+            octstr_format_append(data, "&%E=%E", tmp, dict_get(mdata->values, tmp));
             octstr_destroy(tmp);
         }
+
         gwlist_destroy(l, octstr_destroy_item);
         mdata = mdata->next;
     } while(mdata != NULL);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.