Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Plain Craft Launcher 2/Modules/Base/ModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3213,6 +3213,20 @@ public static object GetObjectFromXML(string str)
Replace("EventData=\"", "local:CustomEventService.EventData=\"").
Replace("Property=\"EventType\"", "Property=\"local:CustomEventService.EventType\"").
Replace("Property=\"EventData\"", "Property=\"local:CustomEventService.EventData\"");

// 自定义主页 XAML 被视为不受信任内容;禁止引用 WPF Behaviors 中可调用方法/改写属性的通用动作。
foreach (var blockedXamlNamespace in new[]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think u can make a static readonly array

{
"Microsoft.Xaml.Behaviors",
"Microsoft.Xaml.Behaviors.Core",
"Microsoft.Xaml.Interactions.Core",
"http://schemas.microsoft.com/xaml/behaviors"
})
{
if (str.Contains(blockedXamlNamespace, StringComparison.OrdinalIgnoreCase))
throw new UnauthorizedAccessException($"不允许使用 {blockedXamlNamespace} 命名空间。");
}

using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str)))
{
// 类型检查
Expand Down
Loading