Encode/Decode on import/export group from/to sync server
Benjamin Renard

Benjamin Renard commited on 2014-01-12 22:04:03
Showing 1 changed files, with 8 additions and 8 deletions.

... ...
@@ -113,7 +113,7 @@ function Group(name,data) {
113 113
       contributions.push(this.contributions[idx].export());
114 114
     }
115 115
     return {
116
-      'name': this.name,
116
+      'name': encodeURIComponent(this.name),
117 117
       'contributors': contributors,
118 118
       'contributions': contributions
119 119
     };
... ...
@@ -223,8 +223,8 @@ function Group(name,data) {
223 223
       if (jQuery.type(data.contributors) == 'array') {
224 224
         for (idx in data.contributors) {
225 225
           this.contributors.push(new Contributor(
226
-            data.contributors[idx].name,
227
-            data.contributors[idx].email,
226
+            decodeURIComponent(data.contributors[idx].name),
227
+            decodeURIComponent(data.contributors[idx].email),
228 228
             idx
229 229
           ));
230 230
         }
... ...
@@ -234,7 +234,7 @@ function Group(name,data) {
234 234
           this.contributions.push(new Contribution(
235 235
             this.contributorByName(data.contributions[idx].contributor),
236 236
             data.contributions[idx].cost,
237
-            data.contributions[idx].title,
237
+            decodeURIComponent(data.contributions[idx].title),
238 238
             data.contributions[idx].date,
239 239
             idx,
240 240
             data.contributions[idx].lastChange
... ...
@@ -254,8 +254,8 @@ function Contributor(name,email,id) {
254 254
   this.id=id;
255 255
   this.export=function() {
256 256
     return {
257
-      'name': this.name,
258
-      'email': this.email
257
+      'name': encodeURIComponent(this.name),
258
+      'email': encodeURIComponent(this.email)
259 259
     };
260 260
   }
261 261
 }
... ...
@@ -269,9 +269,9 @@ function Contribution(contributor,cost,title,date,id,lastChange) {
269 269
   this.lastChange=lastChange || new Date().getTime();
270 270
   this.export=function() {
271 271
     return {
272
-      'contributor': this.contributor.name,
272
+      'contributor': encodeURIComponent(this.contributor.name),
273 273
       'cost': this.cost,
274
-      'title': this.title,
274
+      'title': encodeURIComponent(this.title),
275 275
       'date': this.date,
276 276
       'lastChange': this.lastChange,
277 277
     };
278 278