mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 09:47:39 +00:00
Replace '&' with its XML encoded equivalent, before parsing XML.
Added test to check for proper XML parsing with illegal characters.
This commit is contained in:
parent
fd205d3d57
commit
7ca59b92aa
2 changed files with 34 additions and 1 deletions
|
@ -271,6 +271,39 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.AreEqual("", result);
|
Assert.AreEqual("", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetXbmcSeriesPath_special_characters()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var queryResult = @"<xml><record><field>smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/</field></record></xml>";
|
||||||
|
|
||||||
|
var host = "localhost:8080";
|
||||||
|
var username = "xbmc";
|
||||||
|
var password = "xbmc";
|
||||||
|
|
||||||
|
var setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
|
||||||
|
var resetResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat()";
|
||||||
|
var query = String.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)");
|
||||||
|
|
||||||
|
|
||||||
|
//var fakeUdpProvider = mocker.GetMock<EventClient>();
|
||||||
|
var fakeHttp = mocker.GetMock<HttpProvider>();
|
||||||
|
fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("<xml><tag>OK</xml>");
|
||||||
|
fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"<html>
|
||||||
|
<li>OK
|
||||||
|
</html>");
|
||||||
|
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
result.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/");
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Clean()
|
public void Clean()
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,7 +187,7 @@ namespace NzbDrone.Core.Providers
|
||||||
if (String.IsNullOrEmpty(response))
|
if (String.IsNullOrEmpty(response))
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
var xDoc = XDocument.Load(new StringReader(response));
|
var xDoc = XDocument.Load(new StringReader(response.Replace("&", "&")));
|
||||||
var xml = (from x in xDoc.Descendants("xml") select x).FirstOrDefault();
|
var xml = (from x in xDoc.Descendants("xml") select x).FirstOrDefault();
|
||||||
|
|
||||||
if (xml == null)
|
if (xml == null)
|
||||||
|
|
Loading…
Reference in a new issue