Răsfoiți Sursa

fix: fix off-by-one error in `GetAttributeValue`

Co-authored-by: fearnlj01 <fearnlj01@gmail.com>
Mikal Stordal 1 an în urmă
părinte
comite
d3b9ebfa2e
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      Emby.Server.Implementations/Library/PathExtensions.cs

+ 3 - 2
Emby.Server.Implementations/Library/PathExtensions.cs

@@ -31,8 +31,9 @@ namespace Emby.Server.Implementations.Library
 
 
             var attributeIndex = str.IndexOf(attribute, StringComparison.OrdinalIgnoreCase);
             var attributeIndex = str.IndexOf(attribute, StringComparison.OrdinalIgnoreCase);
 
 
-            // Must be at least 3 characters after the attribute =, ], any character.
-            var maxIndex = str.Length - attribute.Length - 3;
+            // Must be at least 3 characters after the attribute =, ], any character,
+            // then we offset it by 1, because we want the index and not length.
+            var maxIndex = str.Length - attribute.Length - 2;
             while (attributeIndex > -1 && attributeIndex < maxIndex)
             while (attributeIndex > -1 && attributeIndex < maxIndex)
             {
             {
                 var attributeEnd = attributeIndex + attribute.Length;
                 var attributeEnd = attributeIndex + attribute.Length;