diff --git a/src/BiliLite.UWP/Extensions/DynamicParseExtensions.cs b/src/BiliLite.UWP/Extensions/DynamicParseExtensions.cs
index 69aa4e33..4bb1ead3 100644
--- a/src/BiliLite.UWP/Extensions/DynamicParseExtensions.cs
+++ b/src/BiliLite.UWP/Extensions/DynamicParseExtensions.cs
@@ -9,6 +9,7 @@
using BiliLite.Models.Common;
using BiliLite.Models.Common.UserDynamic;
using BiliLite.Models.Dynamic;
+using BiliLite.Models.Exceptions;
using BiliLite.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -118,6 +119,11 @@ public static RichTextBlock UserDynamicStringToRichText(
{1}
{0}
", input, titlePara);
+ if (!xaml.IsXmlString())
+ {
+ throw new CustomizedErrorException("不是有效的xml字符串");
+ }
+
var p = (RichTextBlock)XamlReader.Load(xaml);
return p;
diff --git a/src/BiliLite.UWP/Extensions/StringExtensions.cs b/src/BiliLite.UWP/Extensions/StringExtensions.cs
index 6ff692b5..289cfc80 100644
--- a/src/BiliLite.UWP/Extensions/StringExtensions.cs
+++ b/src/BiliLite.UWP/Extensions/StringExtensions.cs
@@ -16,6 +16,8 @@
using Windows.Storage.Streams;
using System.Threading.Tasks;
using System.Linq;
+using System.Xml;
+using BiliLite.Models.Exceptions;
namespace BiliLite.Extensions
{
@@ -120,6 +122,10 @@ public static RichTextBlock ToRichTextBlock(this string txt, JObject emote, bool
fontColor == null ? "" : $"Foreground=\"{fontColor}\"",
$"FontWeight=\"{fontWeight}\"",
lowProfilePrefix);
+ if (!xaml.IsXmlString())
+ {
+ throw new CustomizedErrorException("不是有效的xml字符串");
+ }
var p = (RichTextBlock)XamlReader.Load(xaml);
return p;
}
@@ -332,6 +338,23 @@ public static string UrlEncode(this string text)
return Uri.EscapeDataString(text);
}
+ public static bool IsXmlString(this string text)
+ {
+ if (string.IsNullOrEmpty(text)) return false;
+ var detail = text.Trim();
+ if (!detail.StartsWith("<") && !detail.EndsWith(">")) return false;
+ var xml = new XmlDocument();
+ try
+ {
+ xml.LoadXml($"{detail}");
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
#region Private methods
///
diff --git a/src/BiliLite.UWP/ViewModels/UserDynamic/DynamicV2ItemViewModel.cs b/src/BiliLite.UWP/ViewModels/UserDynamic/DynamicV2ItemViewModel.cs
index d233185d..8f662708 100644
--- a/src/BiliLite.UWP/ViewModels/UserDynamic/DynamicV2ItemViewModel.cs
+++ b/src/BiliLite.UWP/ViewModels/UserDynamic/DynamicV2ItemViewModel.cs
@@ -140,11 +140,6 @@ public RichTextBlock Content
{
try
{
- if (CardType == Constants.DynamicTypes.ARTICLE && OpusSummary != null)
- {
- var text = OpusSummary.Summary.Text.Nodes.Aggregate("", (current, textNode) => current + textNode.RawText);
- return text.GetSimpleRichTextBlock();
- }
if (Desc != null)
{
return