Merge lp:~mikemc/ubuntuone-credentials/token-tweaks into lp:ubuntuone-credentials

Proposed by Mike McCracken
Status: Merged
Approved by: dobey
Approved revision: 34
Merged at revision: 30
Proposed branch: lp:~mikemc/ubuntuone-credentials/token-tweaks
Merge into: lp:ubuntuone-credentials
Prerequisite: lp:~mikemc/ubuntuone-credentials/register-save-email
Diff against target: 58 lines (+10/-6)
2 files modified
libubuntuoneauth/token.cpp (+8/-4)
libubuntuoneauth/token.h (+2/-2)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-credentials/token-tweaks
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+171345@code.launchpad.net

Commit message

- mark two methods of Token as const, and fix a leak from oauth library

Description of the change

Token improvements

- mark const methods as const, so we can call signUrl on a const reference Token from a Qt signal handler.

- fix leak of header string from oauth_serialize_url_sep

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
33. By Mike McCracken

Merged fix-registration into token-tweaks.

34. By Mike McCracken

Merged fix-registration into token-tweaks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntuoneauth/token.cpp'
2--- libubuntuoneauth/token.cpp 2013-06-28 20:42:26 +0000
3+++ libubuntuoneauth/token.cpp 2013-07-02 19:47:26 +0000
4@@ -68,7 +68,7 @@
5 *
6 * Check that the token is valid.
7 **/
8- bool Token::isValid()
9+ bool Token::isValid() const
10 {
11 return (_tokenHash.contains(TOKEN_NAME_KEY) &&
12 _tokenHash.contains(TOKEN_TOKEN_KEY) &&
13@@ -83,12 +83,13 @@
14 *
15 * Sign a URL with the token.
16 */
17- QString Token::signUrl(const QString url, const QString method, bool asQuery)
18+ QString Token::signUrl(const QString url, const QString method, bool asQuery) const
19 {
20 static const QString hdrPrefix("OAuth ");
21 QString result;
22 int argc = 0;
23 char **argv = NULL;
24+ char *req_hdr = NULL;
25
26 argc = oauth_split_url_parameters(url.toUtf8().data(), &argv);
27 // Fixup the URL as liboauth is escaping '+' to ' ' in it, incorrectly.
28@@ -103,9 +104,12 @@
29 _tokenHash[TOKEN_TOKEN_SEC_KEY].toUtf8().data());
30 if (asQuery)
31 result = oauth_serialize_url_parameters(argc, argv);
32- else
33- result = hdrPrefix + oauth_serialize_url_sep(argc, 1, argv, (char *)", ", 6);
34+ else{
35+ req_hdr = oauth_serialize_url_sep(argc, 1, argv, (char *)", ", 6);
36+ result = hdrPrefix + QString(req_hdr);
37+ }
38 oauth_free_array(&argc, &argv);
39+ free(req_hdr);
40
41 return result;
42 }
43
44=== modified file 'libubuntuoneauth/token.h'
45--- libubuntuoneauth/token.h 2013-05-24 21:09:26 +0000
46+++ libubuntuoneauth/token.h 2013-07-02 19:47:26 +0000
47@@ -36,9 +36,9 @@
48 QString consumer_key, QString consumer_secret);
49
50 QString toQuery();
51- bool isValid();
52+ bool isValid() const;
53
54- QString signUrl(const QString url, const QString method, bool asQuery = false);
55+ QString signUrl(const QString url, const QString method, bool asQuery = false) const;
56
57 static Token *fromQuery(const QString query);
58 static QString buildTokenName();

Subscribers

People subscribed via source and target branches

to all changes: