From c1ee0d53ddfccd74112ac9db066e345861a7aea9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 6 Apr 2022 18:55:06 +0200 Subject: Soundcloud: fix client_id extraction (no more &, ends with " instead) --- src/plugins/Soundcloud.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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([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); })); } -- cgit v1.2.3