Search for attribute text

This commit is contained in:
Cody Robibero 2021-12-07 17:10:27 -07:00
parent 1df56335ee
commit 3513f5a84b

View File

@ -29,18 +29,19 @@ namespace Emby.Server.Implementations.Library
} }
var openBracketIndex = str.IndexOf('['); var openBracketIndex = str.IndexOf('[');
var equalsIndex = str.IndexOf('='); var attributeIndex = str.IndexOf(attribute);
var closingBracketIndex = str.IndexOf(']'); var closingBracketIndex = str.IndexOf(']');
while (openBracketIndex < equalsIndex && equalsIndex < closingBracketIndex) while (openBracketIndex < attributeIndex && attributeIndex < closingBracketIndex)
{ {
if (str[(openBracketIndex + 1)..equalsIndex].Equals(attribute, StringComparison.OrdinalIgnoreCase)) if (openBracketIndex + 1 == attributeIndex
&& str[attributeIndex + attribute.Length] == '=')
{ {
return str[(equalsIndex + 1)..closingBracketIndex].Trim().ToString(); return str[(attributeIndex + attribute.Length + 1)..closingBracketIndex].Trim().ToString();
} }
str = str[(closingBracketIndex + 1)..]; str = str[(closingBracketIndex + 1)..];
openBracketIndex = str.IndexOf('['); openBracketIndex = str.IndexOf('[');
equalsIndex = str.IndexOf('='); attributeIndex = str.IndexOf(attribute);
closingBracketIndex = str.IndexOf(']'); closingBracketIndex = str.IndexOf(']');
} }