{"action":"closed","issue":{"url":"https://api.github.com/repos/mopidy/mopidy/issues/1067","labels_url":"https://api.github.com/repos/mopidy/mopidy/issues/1067/labels{/name}","comments_url":"https://api.github.com/repos/mopidy/mopidy/issues/1067/comments","events_url":"https://api.github.com/repos/mopidy/mopidy/issues/1067/events","html_url":"https://github.com/mopidy/mopidy/issues/1067","id":63471373,"number":1067,"title":"Protect against clients using the search API incorrectly.","user":{"login":"adamcik","id":82534,"avatar_url":"https://avatars.githubusercontent.com/u/82534?v=3","gravatar_id":"","url":"https://api.github.com/users/adamcik","html_url":"https://github.com/adamcik","followers_url":"https://api.github.com/users/adamcik/followers","following_url":"https://api.github.com/users/adamcik/following{/other_user}","gists_url":"https://api.github.com/users/adamcik/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcik/subscriptions","organizations_url":"https://api.github.com/users/adamcik/orgs","repos_url":"https://api.github.com/users/adamcik/repos","events_url":"https://api.github.com/users/adamcik/events{/privacy}","received_events_url":"https://api.github.com/users/adamcik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mopidy/mopidy/labels/2%20-%20Working","name":"2 - Working","color":"CCCCCC"},{"url":"https://api.github.com/repos/mopidy/mopidy/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/mopidy/mopidy/labels/Core","name":"Core","color":"fad8c7"}],"state":"closed","locked":false,"assignee":{"login":"adamcik","id":82534,"avatar_url":"https://avatars.githubusercontent.com/u/82534?v=3","gravatar_id":"","url":"https://api.github.com/users/adamcik","html_url":"https://github.com/adamcik","followers_url":"https://api.github.com/users/adamcik/followers","following_url":"https://api.github.com/users/adamcik/following{/other_user}","gists_url":"https://api.github.com/users/adamcik/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcik/subscriptions","organizations_url":"https://api.github.com/users/adamcik/orgs","repos_url":"https://api.github.com/users/adamcik/repos","events_url":"https://api.github.com/users/adamcik/events{/privacy}","received_events_url":"https://api.github.com/users/adamcik/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mopidy/mopidy/milestones/30","html_url":"https://github.com/mopidy/mopidy/milestones/v1.0%20-%20Audio%20cleanup%201","labels_url":"https://api.github.com/repos/mopidy/mopidy/milestones/30/labels","id":697828,"number":30,"title":"v1.0 - Audio cleanup 1","description":"","creator":{"login":"jodal","id":43726,"avatar_url":"https://avatars.githubusercontent.com/u/43726?v=3","gravatar_id":"","url":"https://api.github.com/users/jodal","html_url":"https://github.com/jodal","followers_url":"https://api.github.com/users/jodal/followers","following_url":"https://api.github.com/users/jodal/following{/other_user}","gists_url":"https://api.github.com/users/jodal/gists{/gist_id}","starred_url":"https://api.github.com/users/jodal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodal/subscriptions","organizations_url":"https://api.github.com/users/jodal/orgs","repos_url":"https://api.github.com/users/jodal/repos","events_url":"https://api.github.com/users/jodal/events{/privacy}","received_events_url":"https://api.github.com/users/jodal/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":128,"state":"open","created_at":"2014-06-22T08:42:13Z","updated_at":"2015-03-22T22:58:45Z","due_on":"2015-03-21T23:00:00Z","closed_at":null},"comments":4,"created_at":"2015-03-22T00:40:28Z","updated_at":"2015-03-22T22:58:45Z","closed_at":"2015-03-22T22:58:45Z","body":"Playing around with some things today I found out that mopidy-mobile seems to send searches incorrectly. Mopidy-Spotify see it as a search for `\"f\" \"o\" \"o\" \" \" \"f\" \"i\" \"g\" \"h\" \"t\" \"e\" \"r\" \"s\"` while, Mopidy-Local-Sqlite seems to handle it \"correctly\". I suspect we want to normalize the query in core so that we at least call the backends in a consistent way.\r\n\r\nSo input of `\"query\":{\"any\":\"foo fighters\"}` should log a warning and convert the query to `\"query\":{\"any\":[\"foo fighters\"]}`\r\n\r\nAdditionally, we should check if there are bugs related to this in mopidy-mobile and/or mopidy-local-sqlite as I think they differ from the intended behavior for the API.\r\n\r\n/me looks forward to switching to a new search API sometime in the future.\r\n\r\n```\r\n2015-03-21 23:32:53,642 DEBUG    [HttpServer] /home/adamcik/dev/mopidy/mopidy/http/handlers.py:115\r\n  mopidy.http.handlers Received WebSocket message from 127.0.0.1: u'{\"method\":\"core.library.search\",\"params\":{\"query\":{\"any\":\"foo fighters\"},\"uris\":null},\"jsonrpc\":\"2.0\",\"id\":1}'\r\n2015-03-21 23:32:53,644 DEBUG    [LocalBackend-3] /home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/mopidy_local_sqlite/schema.py:224\r\n  mopidy_local_sqlite.schema SQLite search query [u'foo fighters']: \r\nSELECT *\r\n  FROM tracks\r\n WHERE docid IN (SELECT docid FROM fts WHERE fts MATCH ?)\r\n\r\n2015-03-21 23:32:53,747 DEBUG    [Core-9] /home/adamcik/dev/mopidy-spotify-2/mopidy_spotify/utils.py:15\r\n  mopidy_spotify.utils Playlist fetch took 101ms\r\n2015-03-21 23:32:53,747 DEBUG    [SpotifyBackend-5] /home/adamcik/dev/mopidy-spotify-2/mopidy_spotify/library.py:230\r\n  mopidy_spotify.library Searching Spotify for: \"f\" \"o\" \"o\" \" \" \"f\" \"i\" \"g\" \"h\" \"t\" \"e\" \"r\" \"s\"\r\n```\r\n\r\n<!---\r\n@huboard:{\"order\":669.375,\"milestone_order\":1067,\"custom_state\":\"\"}\n-->\r\n"}}