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/hgc/hgc.c src/hg/hgc/hgc.c
index 4222db1b9c7..07969fcd50e 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -296,43 +296,30 @@
 char mousedb[] = "mm3";
 
 #define NUMTRACKS 9
 int prevColor[NUMTRACKS]; /* used to optimize color change html commands */
 int currentColor[NUMTRACKS]; /* used to optimize color change html commands */
 int maxShade = 9;	/* Highest shade in a color gradient. */
 Color shadesOfGray[10+1];	/* 10 shades of gray from white to black */
 
 Color shadesOfRed[16];
 boolean exprBedColorsMade = FALSE; /* Have the shades of red been made? */
 int maxRGBShade = 16;
 
 struct bed *sageExpList = NULL;
 char ncbiOmimUrl[255] = {"https://www.ncbi.nlm.nih.gov/omim/"};
 
-char *hubEncode(struct trackDb *tdb, char *text)
-/* Return text escaped for HTML if it belongs to a track hub, otherwise return it unchanged.
- * A hub's trackDb, autoSql schema and data file are all written by a stranger, so anything
- * from them has to be escaped before it goes in the page.  Our own tracks are a
- * different case: they put real HTML in fields on purpose - ClinVar's review-status stars,
- * the CRISPR track's links in an extra column, the <BR> in the Denisova schema comments -
- * and escaping those would print the markup instead of rendering it. */
-{
-if (text != NULL && tdb != NULL && isHubTrack(tdb->track))
-    return htmlEncode(text);
-return text;
-}
-
 struct palInfo
 {
     char *chrom;
     int left;
     int right;
     char *rnaName;
 };
 
 
 /* See this NCBI web doc for more info about entrezFormat:
  * https://www.ncbi.nlm.nih.gov/entrez/query/static/linking.html */
 char *entrezFormat = "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Search&db=%s&term=%s&doptcmdl=%s&tool=genome.ucsc.edu";
 char *entrezPureSearchFormat = "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=PureSearch&db=%s&details_term=%s[%s] ";
 char *ncbiGeneFormat = "https://www.ncbi.nlm.nih.gov/gene/%s";
 char *entrezUidFormat = "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=%s&list_uids=%d&dopt=%s&tool=genome.ucsc.edu";