diff -Nru libmacaroons-0.2.0/debian/changelog libmacaroons-0.2.0/debian/changelog --- libmacaroons-0.2.0/debian/changelog 2015-01-21 12:17:39.000000000 +0000 +++ libmacaroons-0.2.0/debian/changelog 2015-01-21 15:44:29.000000000 +0000 @@ -1,3 +1,16 @@ +libmacaroons (0.2.0-6) trusty; urgency=medium + + * serialize vid and cl in json serialization + https://github.com/rogpeppe/libmacaroons/pull/1 + + -- Jay Wren Wed, 21 Jan 2015 10:44:29 -0500 + +libmacaroons (0.2.0-5) utopic; urgency=medium + + * Build-Depend on dh-autoreconf - utopic too + + -- Jay Wren Wed, 21 Jan 2015 07:18:36 -0500 + libmacaroons (0.2.0-4) trusty; urgency=medium * Build-Depend on dh-autoreconf diff -Nru libmacaroons-0.2.0/macaroons.c libmacaroons-0.2.0/macaroons.c --- libmacaroons-0.2.0/macaroons.c 2015-01-21 11:53:56.000000000 +0000 +++ libmacaroons-0.2.0/macaroons.c 2015-01-21 15:43:28.000000000 +0000 @@ -1395,8 +1395,12 @@ return -1; } - if (!json_object_object_get_ex(obj, key, &child) || - !json_object_is_type(child, json_type_string)) + if (!json_object_object_get_ex(obj, key, &child)) + { + // The field does not exist in the JSON - ignore it. + return 0; + } + if (!json_object_is_type(child, json_type_string)) { *err = MACAROON_INVALID; return -1; @@ -1510,7 +1514,6 @@ { cav = json_object_array_get_idx(arr, idx); - /* TODO deserialize caveat vid and location. */ if (!cav || !json_object_is_type(cav, json_type_object)) { free(M); @@ -1519,12 +1522,28 @@ *err = MACAROON_INVALID; return NULL; } - if (json_help_copy_kv_packet(cav, CID, create_cid_packet, &M->caveats[idx].cid, ENCODING_RAW, &ptr, err) < 0) { free(M); json_object_put(obj); json_tokener_free(tok); + *err = MACAROON_INVALID; + return NULL; + } + if (json_help_copy_kv_packet(cav, VID, create_vid_packet, &M->caveats[idx].vid, ENCODING_BASE64, &ptr, err) < 0) + { + free(M); + json_object_put(obj); + json_tokener_free(tok); + *err = MACAROON_INVALID; + return NULL; + } + if (json_help_copy_kv_packet(cav, CL, create_cl_packet, &M->caveats[idx].cl, ENCODING_RAW, &ptr, err) < 0) + { + free(M); + json_object_put(obj); + json_tokener_free(tok); + *err = MACAROON_INVALID; return NULL; } }