aca9143822a9c12b16b33d479a5abb6495b6b4f0
braney
  Wed Aug 19 06:59:39 2026 -0700
lib, hgc, hgTables, hgHubConnect: share hubEncode, refs #38123

hgc.c and hgTables.c each had their own copy of hubEncode().  The two
bodies were identical, so move the function to hubConnect.c next to
isHubTrack() and let both CGIs call the one definition.

Also use cgiEncode() rather than htmlEncode() for the db= value in the
hgHubConnect assembly list.  That value goes in a query string, so
cgiEncode() is the right function there.  Genome names are already
limited to a safe character set, so this changes no output today.

diff --git src/hg/inc/hubConnect.h src/hg/inc/hubConnect.h
index 5b8ee7548ba..9b14a57489d 100644
--- src/hg/inc/hubConnect.h
+++ src/hg/inc/hubConnect.h
@@ -50,30 +50,35 @@
 #define hgHubDo            hgHub   "do_"    /* prefix for all commands */
 #define hgHubDoClear       hgHubDo "clear"
 #define hgHubDoRefresh     hgHubDo "refresh"
 #define hgHubDoSearch      hgHubDo "search"
 #define hgHubDoDeleteSearch      hgHubDo "deleteSearch"
 #define hgHubDoFilter      hgHubDo "filter"
 #define hgHubDoDisconnect  hgHubDo "disconnect"
 #define hgHubDoFirstDb     hgHubDo "firstDb"
 #define hgHubDoDecorateDb  hgHubDo "decorateDb"
 #define hgHubDoRedirect    hgHubDo "redirect"
 #define hgHubDoHubCheck    hgHubDo "hubCheck"
 
 boolean isHubTrack(char *trackName);
 /* Return TRUE if it's a hub track. */
 
+struct trackDb;
+
+char *hubEncode(struct trackDb *tdb, char *text);
+/* Return text escaped for HTML if it belongs to a track hub, otherwise return it unchanged. */
+
 struct hubConnectStatus
 /* Basic status in hubStatus.  Note it is *not* the same as the
  * hubStatus table, that has a bunch of extra fields to help 
  * keep track of whether the hub is alive. */
     {
     struct hubConnectStatus *next;
     unsigned id;	/* Hub ID */
     char *hubUrl;	/* URL to hub.ra file. */
     char *shortLabel;   /* shortLabel from hubStatus table. */
     char *errorMessage;	/* If non-empty hub has an error and this describes it. */
     struct trackHub *trackHub; /* pointer to structure that describes hub */
     unsigned  status;   /* 1 if private */
     };