Greetings!
We have a customer who is using the old Search Module which is using the project Dynamicweb.WeightedSearch Project.
They have recently been upgraded to 9.8.8, and the search fails because of an Null Reference.
Would it be possible to add a Null Check in the Method Highlight?
I have to test this added the null check:
private string Highlight(string text, string word)
{
if (!string.IsNullOrWhiteSpace(text))
{
string[] arrWord = SplitSearchPhrase(word);
for (int i = 0; i <= arrWord.GetUpperBound(0); i++)
{
word = arrWord[i];
if (word.Substring(0, 1) == "+")
{
word = "\\" + word;
}
if (word != string.Empty)
{
string pattern = "(\\b" + Regex.Escape(word) + "\\b)";
string replacePattern = "<strong>$1</strong>";
Regex regEx = new Regex(pattern, RegexOptions.IgnoreCase);
text = regEx.Replace(text, replacePattern);
}
string encodedPhrase = Searchv1_EncodedSearchPhrases(word);
if (encodedPhrase != string.Empty)
{
if (encodedPhrase.Substring(0, 1) == "+")
{
encodedPhrase = "\\" + encodedPhrase;
}
if (!(encodedPhrase == null))
{
string pattern = "(\\b" + Regex.Escape(encodedPhrase) + "\\b)";
string replacePattern = "<strong>$1</strong>";
Regex regEx = new Regex(pattern, RegexOptions.IgnoreCase);
text = regEx.Replace(text, replacePattern);
}
}
}
}
return text;
}