From 3911da5c6169877988b061d1de9b475f5789ba69 Mon Sep 17 00:00:00 2001 From: Andreas Obergrusberger Date: Fri, 18 Jan 2008 13:53:06 +0000 Subject: [PATCH] improve escaping of URLs git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@7141 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- ChangeLog | 3 +++ src/lyrics_leoslyrics.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7df175..6426ff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2008-01-18 Andreas Obergrusberger + * improve escaping of URLs + 2008-01-07 Andreas Obergrusberger * Jose updated the slovak translation diff --git a/src/lyrics_leoslyrics.c b/src/lyrics_leoslyrics.c index 4afb3fa..99dac9d 100644 --- a/src/lyrics_leoslyrics.c +++ b/src/lyrics_leoslyrics.c @@ -95,13 +95,14 @@ static void fetch_text(void *userData, const XML_Char *s, int len) int check_lyr_leoslyrics(char *artist, char *title, char *url) { char url_avail[256]; + CURL *curl = curl_easy_init (); + //this replacess the whitespaces with '+' - g_strdelimit(artist, " ", '+'); - g_strdelimit(title, " ", '+'); - + char *esc_title = curl_easy_escape (curl, title, 0); + char *esc_artist = curl_easy_escape (curl, artist, 0); //we insert the artist and the title into the url - snprintf(url_avail, 512, LEOSLYRICS_SEARCH_URL, artist, title); + snprintf(url_avail, 512, LEOSLYRICS_SEARCH_URL, esc_artist, esc_title); //download that xml! easy_download_struct lyr_avail = {NULL, 0,-1}; @@ -121,7 +122,6 @@ int check_lyr_leoslyrics(char *artist, char *title, char *url) if(!(result & 4)) return -1; //check whether lyrics found - CURL *curl = curl_easy_init (); char *esc_hid = curl_easy_escape (curl, hid, 0); free (hid); -- 2.30.2