mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-28 06:41:15 -04:00
+ fix escaping problem by kiwix-serve suggestions
This commit is contained in:
parent
20771de512
commit
0f7c1d812d
@ -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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user