Răsfoiți Sursa

Fixed issue with satellite files having whitespace characters.

Vicente Penades 5 ani în urmă
părinte
comite
500956a474

+ 2 - 0
src/Shared/Guard.cs

@@ -208,6 +208,8 @@ namespace SharpGLTF
 
             if (gltfURI.StartsWith("data:")) throw new ArgumentException($"Invalid URI '{gltfURI}'.");
 
+            gltfURI = Uri.EscapeUriString(gltfURI);
+
             if (!Uri.IsWellFormedUriString(gltfURI, UriKind.RelativeOrAbsolute)) throw new ArgumentException($"Invalid URI '{gltfURI}'.");
             if (!Uri.TryCreate(gltfURI, UriKind.RelativeOrAbsolute, out Uri xuri)) throw new ArgumentException($"Invalid URI '{gltfURI}'.");
 

+ 10 - 0
tests/Assets/white space.gltf

@@ -0,0 +1,10 @@
+{
+    "asset": {
+        "version": "2.0"
+    },    
+    "images": [
+        {
+            "uri": "white space.jpg"
+        }
+    ]
+}

BIN
tests/Assets/white space.jpg


+ 13 - 0
tests/SharpGLTF.Tests/Schema2/LoadAndSave/LoadSpecialModelsTest.cs

@@ -24,6 +24,19 @@ namespace SharpGLTF.Schema2.LoadAndSave
 
         #endregion
 
+        [Test]
+        public void LoadWithWhiteSpaceTexture()
+        {
+            TestContext.CurrentContext.AttachShowDirLink();
+
+            var path = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, "Assets\\white space.gltf");
+
+            var model = ModelRoot.Load(path);
+            Assert.NotNull(model);
+
+            model.AttachToCurrentTest("white space.glb");
+        }
+
         public void LoadWithCustomImageLoader()
         {
             TestContext.CurrentContext.AttachShowDirLink();            

+ 7 - 9
tests/SharpGLTF.Tests/SharpGLTF.Core.Tests.csproj

@@ -5,11 +5,15 @@
     <IsPackable>false</IsPackable>
     <RootNamespace>SharpGLTF</RootNamespace>
     <LangVersion>latest</LangVersion>
-  </PropertyGroup> 
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Content Include="..\Assets\**" LinkBase="Assets" CopyToOutputDirectory="PreserveNewest" />
+  </ItemGroup>
 
   <ItemGroup>    
     <ProjectReference Include="..\SharpGLTF.NUnit\SharpGLTF.NUnit.csproj" />
-  </ItemGroup>
+  </ItemGroup>  
 
   <ItemGroup>
     
@@ -23,12 +27,6 @@
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <None Update="Assets\**">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>    
-  </ItemGroup>
+  </ItemGroup>  
 
 </Project>