660c13fee76b94704905eaf5c248579cc18ad5db chmalee Wed Apr 26 16:56:18 2023 -0700 Erase leading and trailing whitespace from hgGateway database search string, refs #30257 diff --git src/hg/hgGateway/hgGateway.c src/hg/hgGateway/hgGateway.c index 77776af..2df826f 100644 --- src/hg/hgGateway/hgGateway.c +++ src/hg/hgGateway/hgGateway.c @@ -898,31 +898,33 @@ hubSearchTableName, term); hubDbUrlList = sqlQuickList(conn, query); aHubMatchList = filterHubSearchTextMatches(dbDbList, hubDbUrlList); } } hDisconnectCentral(&conn); return aHubMatchList; } static char *getSearchTermUpperCase() /* If we don't have the SEARCH_TERM cgi param, exit with an HTTP Bad Request response. * If we do, convert it to upper case for case-insensitive matching and return it. */ { pushWarnHandler(htmlVaBadRequestAbort); pushAbortHandler(htmlVaBadRequestAbort); -char *term = cgiOptionalString(SEARCH_TERM); +char *cgiTerm = cgiOptionalString(SEARCH_TERM); +char *term = skipLeadingSpaces(cgiTerm); +eraseTrailingSpaces(term); touppers(term); if (isEmpty(term)) errAbort("Missing required CGI parameter %s", SEARCH_TERM); popWarnHandler(); popAbortHandler(); return term; } static void lookupTerm() /* Look for matches to term in hgcentral and print as JSON for autocomplete if found. */ { char *term = getSearchTermUpperCase(); // Write JSON response with list of matches puts("Content-Type:text/javascript\n");