aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Soundcloud.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp
index 0412aa6..e088f73 100644
--- a/src/plugins/Soundcloud.cpp
+++ b/src/plugins/Soundcloud.cpp
@@ -382,15 +382,24 @@ namespace QuickMedia {
async_download_tasks.push_back(AsyncTask<std::string>([script_source]() -> std::string {
std::string website_data;
DownloadResult download_result = download_to_string(script_source, website_data, {}, true);
- if(download_result != DownloadResult::OK) return "";
+ if(download_result != DownloadResult::OK)
+ return "";
size_t index = website_data.find("client_id=");
- if(index == std::string::npos) return "";
+ if(index == std::string::npos)
+ return "";
index += 10;
- size_t end = website_data.find('&', index);
- if(end == std::string::npos) end = website_data.size();
- return website_data.substr(index, end - index);
+ const size_t start_next_arg = website_data.find('&', index);
+ const size_t start_end_of_str = website_data.find('"', index);
+ if(start_next_arg == std::string::npos && start_end_of_str == std::string::npos)
+ return "";
+
+ size_t min_end = start_next_arg;
+ if(min_end == std::string::npos || start_end_of_str < min_end)
+ min_end = start_end_of_str;
+
+ return website_data.substr(index, min_end - index);
}));
}