Skip to content

Commit

Permalink
fix qq music resolve xml document bugs #135
Browse files Browse the repository at this point in the history
  • Loading branch information
jitwxs committed Dec 3, 2022
1 parent 88296c9 commit 0d352bb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion MusicLyricApp/Utils/XmlUtils.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

namespace MusicLyricApp.Utils
{
public static class XmlUtils
{
private static Regex _badAmpersand = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)");

private static string _goodAmpersand = "&";

/// <summary>
/// 创建 XML DOM
/// </summary>
Expand All @@ -15,6 +19,9 @@ public static XmlDocument Create(string content)
{
content = RemoveIllegalContent(content);

// replace & symbol
content = _badAmpersand.Replace(content, _goodAmpersand);

var doc = new XmlDocument();

doc.LoadXml(content);
Expand Down

0 comments on commit 0d352bb

Please sign in to comment.