CA-352455: Parse the task result as xml document instead of using a regex.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2021-03-08 16:47:10 +00:00
parent 96956dbc81
commit 47d9146ce3
2 changed files with 10 additions and 13 deletions

View File

@ -34,6 +34,7 @@ using System.Collections.Generic;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using XenAdmin.Core;
using XenAdmin.Network;
using XenAPI;
@ -366,9 +367,15 @@ namespace XenAdmin.Actions
log.InfoFormat("Task {0} finished successfully", RelatedTask.opaque_ref);
if (task.result != "") // Work around CA-6597
{
Match m = Regex.Match(task.result, "<value>(.*)</value>");
if (m.Success)
Result = m.Groups[1].Value;
var doc = new XmlDocument();
doc.LoadXml(task.result);
var nodes = doc.GetElementsByTagName("value");
foreach (XmlNode node in nodes)
{
Result = node.InnerText;
break;
}
}
return true;

View File

@ -538,16 +538,6 @@ namespace XenAPI
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
// If we've got this from an async task result, then it will be wrapped
// in a <value> element. Parse the contents instead.
foreach (XmlNode node in doc.GetElementsByTagName("value"))
{
xml = node.InnerText;
doc = new XmlDocument();
doc.LoadXml(xml);
break;
}
foreach (XmlNode node in doc.GetElementsByTagName("SR"))
{
string uuid = "";