V8: Wildcards in tree searches causes YSODs (#7330)

This commit is contained in:
Kenn Jacobsen
2020-07-30 13:54:28 +02:00
committed by GitHub
parent e390820f2e
commit e25a81ef38
2 changed files with 6 additions and 1 deletions

View File

@@ -744,7 +744,9 @@ namespace Umbraco.Core.Persistence.Querying
var c = exp[0];
return (c == '"' || c == '`' || c == '\'') && exp[exp.Length - 1] == c
? exp.Substring(1, exp.Length - 2)
? exp.Length == 1
? string.Empty
: exp.Substring(1, exp.Length - 2)
: exp;
}
}

View File

@@ -186,6 +186,9 @@ namespace Umbraco.Web.Search
var allLangs = _languageService.GetAllLanguages().Select(x => x.IsoCode.ToLowerInvariant()).ToList();
// the chars [*-_] in the query will mess everything up so let's remove those
query = Regex.Replace(query, "[\\*\\-_]", "");
//check if text is surrounded by single or double quotes, if so, then exact match
var surroundedByQuotes = Regex.IsMatch(query, "^\".*?\"$")
|| Regex.IsMatch(query, "^\'.*?\'$");