139e158c2b2817ea64048290f046105d25f97198 braney Tue Aug 18 11:15:51 2026 -0700 hgHubConnect: encode hub label and contact fields consistently, refs #38123 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 65d37febc54..45270e54649 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -82,33 +82,34 @@ static void ourCellStart() { fputs("", stdout); // do not add a newline } static void ourCellEnd() { puts(""); } static void ourPrintCellLink(char *str, char *url) { ourCellStart(); -printf("\n", url); +// every caller passes a hub label and a hub url, both text from a stranger, so escape +printf("\n", htmlEncode(url)); if (str != NULL) - fputs(str, stdout); // do not add a newline -- was causing trailing blanks get copied in cut and paste + fputs(htmlEncode(str), stdout); // do not add a newline -- was causing trailing blanks get copied in cut and paste puts(""); ourCellEnd(); } static void ourPrintCell(char *str) { ourCellStart(); if (str != NULL) fputs(str, stdout); // do not add a newline -- was causing trailing blanks get copied in cut and paste ourCellEnd(); } static char *removeLastComma(char *string) { if (string != NULL) @@ -363,31 +364,31 @@ safef(id, sizeof id, "hubClearButton%d", count); // give people a chance to clear the error printf("" , id); jsOnEventByIdF("click", id, "document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit(); return true;", javaScriptLiteralEncode(hub->hubUrl)); ourCellEnd(); } else if (hub->trackHub != NULL) { if (hub->trackHub->descriptionUrl != NULL) ourPrintCellLink(hub->trackHub->longLabel, hub->trackHub->descriptionUrl); else - ourPrintCell(hub->trackHub->longLabel); + ourPrintCell(htmlEncode(hub->trackHub->longLabel)); // hub supplied } else ourPrintCell(""); if (hub->trackHub != NULL) printGenomes(hub->trackHub, count, !hubHasError); else ourPrintCell(""); puts(""); } printf("\n"); puts(""); @@ -686,31 +687,31 @@ } ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", hubInfo->hubUrl); ourPrintCellLink(hubInfo->shortLabel, hubInfo->hubUrl); boolean hubHasNoError = isEmpty(hubInfo->errorMessage); if (hubHasNoError) { if (hubInfo->tableHasDescriptionField && !isEmpty(hubInfo->descriptionUrl)) ourPrintCellLink(hubInfo->longLabel, hubInfo->descriptionUrl); else - ourPrintCell(hubInfo->longLabel); + ourPrintCell(htmlEncode(hubInfo->longLabel)); // hub supplied } else { ourCellStart(); printf("ERROR: %s " "Debug Help", hubInfo->errorMessage); safef(jsId, sizeof jsId, "hubClearButton%d", count); printf( "" , jsId); jsOnEventByIdF("click", jsId, "document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit();return true;", hubInfo->hubUrl); @@ -1432,52 +1433,54 @@ char *errorMessage; hubFindOrAddUrlInStatusTable(cart, hub->hubUrl, &errorMessage); // if there is an error message, we stay in hgHubConnect if (errorMessage != NULL) return 0; getDbAndGenome(cart, &database, &organism, oldVars); char headerText[1024]; safef(headerText, sizeof(headerText), "Hub Connect Successful"); cartWebStart(cart, NULL, "%s", headerText); struct trackHub *tHub = hub->trackHub; -hPrintf("

Connected Hub: %s

", tHub->shortLabel); +// the labels, the email and the per genome organism and description all come out of the +// hub's own text files, so escape them before printing +hPrintf("

Connected Hub: %s

", htmlEncode(tHub->shortLabel)); -hPrintf("

Hub Description: %s

", tHub->longLabel); -hPrintf("

Contact email: %s. Use this contact for all data questions.

", tHub->email, tHub->email); +hPrintf("

Hub Description: %s

", htmlEncode(tHub->longLabel)); +hPrintf("

Contact email: %s. Use this contact for all data questions.

", htmlEncode(tHub->email), htmlEncode(tHub->email)); struct trackHubGenome *genomeList = tHub->genomeList; hPrintf("

Assemblies: Select an assembly below to start browsing the tracks of this hub:

"); hPrintf("

"); hPrintf("

Connect another hub to add more tracks.

"); hPrintf("

Hubs are created and maintained by external sources. UCSC is not responsible for their content and status.

"); return 1; } static void doResetHub(struct cart *theCart) { char *url = cartOptionalString(cart, hgHubCheckUrl); if (url != NULL)