From 7904313e380660bdb1795dc830200ce8eba5b4da Mon Sep 17 00:00:00 2001 From: NepPure Date: Mon, 15 Jan 2024 10:09:17 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E4=B8=8B=E6=96=9C?= =?UTF-8?q?=E6=9D=A0=E6=9B=BF=E6=8D=A2=E4=B8=8D=E5=AE=8C=E5=85=A8=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=85=BC=E5=AE=B9=E5=8D=8F=E8=AE=AE=E7=BC=A9?= =?UTF-8?q?=E5=86=99=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs index 02dc2488c..6fb358d4f 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs @@ -30,7 +30,10 @@ public void Build(MessageBuilder builder, ISegment segment) if (imageSegment.Url.StartsWith("file")) { - string path = imageSegment.Url.Replace("file://", ""); + // 修复windows下斜杠替换不完全导致的路径问题,同时兼容协议缩写的情况:https://github.com/LagrangeDev/Lagrange.Core/issues/69 + string path = imageSegment.Url.Replace("file:///", ""); + path = path.Replace("file://", ""); + path = path.Replace("file:/", ""); builder.Image(File.ReadAllBytes(path)); } From 7e05f7d4d3bb3a9d35c6dae7564472a7125e76cb Mon Sep 17 00:00:00 2001 From: NepPure Date: Mon, 15 Jan 2024 10:10:52 +0000 Subject: [PATCH 2/3] rm cn --- Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs index 6fb358d4f..1b8c1c943 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs @@ -30,7 +30,7 @@ public void Build(MessageBuilder builder, ISegment segment) if (imageSegment.Url.StartsWith("file")) { - // 修复windows下斜杠替换不完全导致的路径问题,同时兼容协议缩写的情况:https://github.com/LagrangeDev/Lagrange.Core/issues/69 + // see: https://github.com/LagrangeDev/Lagrange.Core/issues/69 string path = imageSegment.Url.Replace("file:///", ""); path = path.Replace("file://", ""); path = path.Replace("file:/", ""); From eae4ac32bb7b4c481b924121017ec5b6ec8d2cd5 Mon Sep 17 00:00:00 2001 From: NepPure Date: Mon, 15 Jan 2024 11:13:21 +0000 Subject: [PATCH 3/3] convert by uri --- Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs index 1b8c1c943..5bbf9297f 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs @@ -30,10 +30,7 @@ public void Build(MessageBuilder builder, ISegment segment) if (imageSegment.Url.StartsWith("file")) { - // see: https://github.com/LagrangeDev/Lagrange.Core/issues/69 - string path = imageSegment.Url.Replace("file:///", ""); - path = path.Replace("file://", ""); - path = path.Replace("file:/", ""); + string path = new Uri(imageSegment.Url).AbsolutePath; builder.Image(File.ReadAllBytes(path)); }