Closed mguntli closed 7 years ago
Sorry was too early with pushing: UrlEncoder does the wrong escaping! --> maybe I should have written a UnitTest for it ;-)
Write a unit test that reproduces your problem please. It will be better for maintenance in future.
How do you paste your URI? Because if they are already escaped, it will break the system as well.. I retrieve the playlists URI from my Sonos Favorites with https://github.com/jishi/Jishi.Intel.SonosUPnP
For the moment with playURI method i only use mp3 or radio feed, and it works well ;)
Hi Valentin
Current approach: detect if the string is already escaped, if not escape the XML characters. https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String)
I will write a corresponding unit test for it with the following test cases:
x-sonosapi-radio:vy_wPy0RZBSA?sid=151&flags=8300&sn=3
x-sonosapi-radio:vy_wPy0RZBSA?sid=151&flags=8300&sn=3
Expected result: x-sonosapi-radio:vy_wPy0RZBSA?sid=151&flags=8300&sn=3
I think i gonna add org.apache.commons.commons-text dependency for this problem. It's more simple.
I agree, my solution is kind of "self-made" since I didn't want to include any external dependency into your library. Please keep in mind that you don't double escape already escaped characters (e.g. "&" should not result in "&"
It's done on master ! Thanks for your help 👍
While I was trying to start a playlist from Google Play Music, I noticed that it didn't work because the special characters were not escaped. <, >, &, " and ' all have special meanings in XML and have to be represented by entities.
Example from Google Play Music:
sonosDevice.playUri("x-sonosapi-radio:vy_wPybY9vRCoaCMySC_D6Ol9WJ1aoH97kTmNIzBZ667Frppf2koUq7ZH7OJ9bXx41s_K0RZBSA?sid=151&flags=8300&sn=3", null);