From b8f73ae6a6dc8a064fde5803e67176bd6af1e80f Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 28 Jan 2009 22:37:46 +0100 Subject: [PATCH] use curl_escape on artist and title tags --- src/lyrics.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 8ef6b08c..b6b98b4e 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -111,7 +111,11 @@ void * GetArtistInfo(void *ptr) CURLcode code; - string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + artist + "&api_key=d94e5b6e26469a2d1ffae8ef20131b79"; + char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length()); + + string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="; + url += c_artist; + url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79"; pthread_mutex_lock(&curl); CURL *info = curl_easy_init(); @@ -124,6 +128,8 @@ void * GetArtistInfo(void *ptr) curl_easy_cleanup(info); pthread_mutex_unlock(&curl); + curl_free(c_artist); + if (code != CURLE_OK) { *sInfo << "Error while fetching artist's info: " << curl_easy_strerror(code); @@ -285,10 +291,13 @@ void *GetLyrics(void *song) string result; + char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length()); + char *c_title = curl_easy_escape(0, title.c_str(), title.length()); + string url = "http://lyricwiki.org/api.php?artist="; - url += artist; + url += c_artist; url += "&song="; - url += title; + url += c_title; url += "&fmt=xml"; pthread_mutex_lock(&curl); @@ -302,6 +311,9 @@ void *GetLyrics(void *song) curl_easy_cleanup(lyrics); pthread_mutex_unlock(&curl); + curl_free(c_artist); + curl_free(c_title); + if (code != CURLE_OK) { *sLyrics << "Error while fetching lyrics: " << curl_easy_strerror(code);