f664e77c7e67c0342ba78b140386c4644d451a32 max Thu Sep 17 01:42:56 2026 -0700 hgHubConnect, lib: name the hub URL when a hub fails to load #Preview2 week - bugs introduced now will need a build patch to fix A hub that could not be opened showed up in the connected-hubs table as an error message and nothing else: the name, description and assembly cells were all empty, because they are only filled in from the trackHub struct that the failed load never produced. The URL was in the row only inside the javascript of the Disconnect and Retry buttons, so there was no way to tell which hub the error was about. Print the URL in the name cell instead. netParseUrl chops up its local copy of the URL as it parses, so none of its errAborts could report what they were looking at. Keep the caller's string and name it in all of them. A URL written with a single slash, https:/host/f, then reported a non-numeric port, because with no :// the protocol defaults to http and the host becomes "https" with an empty port - say what is actually wrong with it. Also tighten the encoding of the hub tables' output and of javascript string literals, and use htmlEncode, not javaScriptLiteralEncode, for the option labels in cgiMakeSelectDropList, which are HTML text. diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 48362310150..707ce725e11 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -347,39 +347,44 @@ ourCellStart(); safef(id, sizeof id, "hubDisconnectButtonU%d", count); printf("\n", id); jsOnEventByIdF("click", id, "removeRecentGenomesByHubUrl('%s');" "document.disconnectHubForm.elements['hubId'].value='%d';" "document.disconnectHubForm.submit(); return true;", javaScriptLiteralEncode(hub->hubUrl), hub->id); ourCellEnd(); if (hub->trackHub != NULL) { ourPrintCellLink(hub->trackHub->shortLabel, hub->hubUrl); } else - ourPrintCell(""); + { + // hub did not open, so we have no short label. Show the url instead, otherwise the + // row is just an error message and there is no way to tell which hub it is about. + ourPrintCell(htmlEncode(hub->hubUrl)); + } boolean hubHasError = (!isEmpty(hub->errorMessage)); if (hubHasError) { ourCellStart(); + // the message usually quotes the hub url back at us, and that came from a stranger printf("ERROR: %s " "Debug Help\n", - hub->errorMessage); + htmlEncode(hub->errorMessage)); 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); @@ -703,41 +708,42 @@ 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(htmlEncode(hubInfo->longLabel)); // hub supplied } else { ourCellStart(); + // the message can quote text that the hub itself supplied, so escape it printf("ERROR: %s " "Debug Help", - hubInfo->errorMessage); + htmlEncode(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); + "document.resetHubForm.submit();return true;", javaScriptLiteralEncode(hubInfo->hubUrl)); ourCellEnd(); } printGenomeList(hubInfo->hubUrl, dbListNames, count, hubHasNoError, FALSE); printf("\n"); } struct trackHub *fetchTrackHub(struct hubEntry *hubInfo) /* Fetch the hub structure for a public hub, trapping the error * if the hub cannot be reached */ { struct errCatch *errCatch = errCatchNew(); struct trackHub *hub = NULL; if (errCatchStart(errCatch)) {