diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 6e4480f..7670d57 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -226,16 +226,19 @@ static int accessHandlerCallback(void *cls, content = "["; reader->searchSuggestions(term, maxSuggestionCount); while (reader->getNextSuggestion(suggestion)) { + kiwix::stringReplacement(suggestion, "\"", "\\\""); content += (content == "[" ? "" : ","); content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; suggestionCount++; } + std::cout << suggestionCount << std::endl; /* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */ if (suggestionCount < 10) { term = kiwix::ucFirst(term); reader->searchSuggestions(term, maxSuggestionCount); while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { + kiwix::stringReplacement(suggestion, "\"", "\\\""); content += (content == "[" ? "" : ","); content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; suggestionCount++; @@ -246,7 +249,8 @@ static int accessHandlerCallback(void *cls, if (suggestionCount < 10) { term = kiwix::lcFirst(term); reader->searchSuggestions(term, maxSuggestionCount); - while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { + while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) + kiwix::stringReplacement(suggestion, "\"", "\\\""); content += (content == "[" ? "" : ","); content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; suggestionCount++;