From 9e21ececff7175e3dd9a2e920e8e8931b11668c8 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 31 May 2018 21:13:24 +0100 Subject: [PATCH] Fix OAuthDialog 'code' parse url .. the code to parse the redirect url and exract the query item 'code' was fragile -- and got broken when Strava added a new query item to the returned URL. .. we now use QUrlQuery to extract in a more robust and future proof way Fixes #2879 --- src/Cloud/OAuthDialog.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Cloud/OAuthDialog.cpp b/src/Cloud/OAuthDialog.cpp index 93d72da10e..11f9a93f22 100644 --- a/src/Cloud/OAuthDialog.cpp +++ b/src/Cloud/OAuthDialog.cpp @@ -242,10 +242,8 @@ OAuthDialog::urlChanged(const QUrl &url) url.toString().contains("blank.html?code=") || url.toString().startsWith("http://www.goldencheetah.org/?code=")) { - QString code = url.toString().right(url.toString().length()-url.toString().indexOf("code=")-5); - - // sporttracks insists on passing state - if (code.endsWith("&state=xyzzy")) code = code.mid(0,code.length()-12); + QUrlQuery parse(url); + QString code=parse.queryItemValue("code"); QByteArray data; #if QT_VERSION > 0x050000