Merge pull request #1079 from mfietz/issue/1075-non-ascii-chars-in-url

Encode non-ascii query strings for the iTunes search
This commit is contained in:
Tom Hennen 2015-08-13 18:27:43 -04:00
commit 878850b924
1 changed files with 15 additions and 3 deletions

View File

@ -22,6 +22,8 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -31,7 +33,7 @@ import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
import de.danoeh.antennapod.adapter.itunes.ItunesAdapter; import de.danoeh.antennapod.adapter.itunes.ItunesAdapter;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import static de.danoeh.antennapod.adapter.itunes.ItunesAdapter.*; import static de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast;
//Searches iTunes store for given string and displays results in a list //Searches iTunes store for given string and displays results in a list
public class ItunesSearchFragment extends Fragment { public class ItunesSearchFragment extends Fragment {
@ -161,7 +163,17 @@ public class ItunesSearchFragment extends Fragment {
* @param query Search string * @param query Search string
*/ */
public SearchTask(String query) { public SearchTask(String query) {
this.query = query; String encodedQuery = null;
try {
encodedQuery = URLEncoder.encode(query, "UTF-8");
} catch(UnsupportedEncodingException e) {
// this won't ever be thrown
}
if(encodedQuery != null) {
this.query = encodedQuery;
} else {
this.query = query; // failsafe
}
} }
//Get the podcast data //Get the podcast data