mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Improve error msg when having bad names xml file
This commit is contained in:
parent
9ecdd5376a
commit
e34a716b96
@ -102,40 +102,43 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
return;
|
||||
}
|
||||
|
||||
using (var reader = XmlReader.Create(fileNameOrUrl))
|
||||
try
|
||||
{
|
||||
reader.MoveToContent();
|
||||
while (reader.Read())
|
||||
using (var reader = XmlReader.Create(fileNameOrUrl))
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
|
||||
reader.MoveToContent();
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.Name == "name")
|
||||
if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
|
||||
{
|
||||
var name = reader.ReadElementContentAsString().Trim();
|
||||
if (name.Length > 0)
|
||||
if (reader.Name == "name")
|
||||
{
|
||||
if (name.Contains(' '))
|
||||
var name = reader.ReadElementContentAsString().Trim();
|
||||
if (name.Length > 0)
|
||||
{
|
||||
_namesMultiList.Add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_namesList.Add(name);
|
||||
if (name.Contains(' '))
|
||||
{
|
||||
_namesMultiList.Add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_namesList.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reader.Name == "blacklist")
|
||||
{
|
||||
while (reader.Read() && reader.NodeType != XmlNodeType.EndElement)
|
||||
else if (reader.Name == "blacklist")
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
|
||||
while (reader.Read() && reader.NodeType != XmlNodeType.EndElement)
|
||||
{
|
||||
if (reader.Name == "name")
|
||||
if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
|
||||
{
|
||||
var name = reader.ReadElementContentAsString().Trim();
|
||||
if (name.Length > 0)
|
||||
if (reader.Name == "name")
|
||||
{
|
||||
_blackList.Add(name);
|
||||
var name = reader.ReadElementContentAsString().Trim();
|
||||
if (name.Length > 0)
|
||||
{
|
||||
_blackList.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,6 +147,10 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Unable to read name list file: " + fileNameOrUrl, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
|
Loading…
Reference in New Issue
Block a user