f759bf663debc22e6015c6c38c22f922bfbdf45b braney Fri Aug 21 10:01:02 2026 -0700 lib, cgilib: sanitize description HTML where it comes in, refs #38126 A track hub's track description, a custom track's documentation, and an assembly hub's genome description are all written by somebody else and were stored and printed as they arrived. Run each through htmlSanitize() at the point it is read, so that everything downstream sees text we are willing to print. Sanitizing on the way in is the only practical place: printTrackHtml() alone has more than a hundred callers, and hgTrackUi, hui.c, hgGene, hgGtexTrackSettings and hgTables all print tdb->html directly. The five places are trackHubAddOneDescription(), customTrack.c where it used to call jsStripJavascript(), the htmlUrl fetch in customFactory.c, hgPositionsHelpHtmlCart() and hAssemblyDescription(). In the last two, only the branch that fetches over the network is touched. The branch that reads a local file is left as it is, because those are our own description.html files. trackHubAddOneDescription() keeps its old shape. The fetch moves into a helper so that trackHubDescriptionRemovals() can hand hubCheck the list of things the filter takes out. diff --git src/hg/inc/trackHub.h src/hg/inc/trackHub.h index f7354f116a4..dbafa092db2 100644 --- src/hg/inc/trackHub.h +++ src/hg/inc/trackHub.h @@ -202,30 +202,34 @@ struct dbDb *trackHubDbDbFromAssemblyDb(char *database); /* Return a dbDb structure for just this database. */ struct hgPositions; void trackHubFindPos(struct cart *cart, char *db, char *term, struct hgPositions *hgp, boolean measureTiming); /* Look for term in track hubs. Update hgp if found */ void trackHubAddDescription(char *trackDbFile, struct trackDb *tdb); /* Fetch tdb->track's html description (or nearest ancestor's non-empty description) * and store in tdb->html. */ void trackHubAddOneDescription(char *trackDbFile, struct trackDb *tdb); /* Fetch tdb->track's html description and store in tdb->html. */ +struct slName *trackHubDescriptionRemovals(char *trackDbFile, struct trackDb *tdb); +/* Return a list of messages naming the parts of tdb's description page that we do not + * print, or NULL if we print all of it. */ + struct trackHubGenome *trackHubGetGenome(char *database); /* get genome structure for an assembly in a trackHub */ boolean trackHubGetBlatParams(char *database, boolean isTrans, char **pHost, char **pPort, char **pGenomeDataDir); /* get "blat" and "transBlat" entries (if any) for an assembly hub */ struct dbDb *trackHubGetBlatDbDbs(); /* Get a list of connected track hubs that have blat servers */ struct slPair *trackHubDbDbToValueLabel(struct dbDb *hubDbDbList); /* Given a trackHub (list of) track hub dbDb which may be missing some info, * return an slPair of value and label suitable for making a select/menu option. */ void hubCheckBigDataUrl(struct trackHub *hub, struct trackHubGenome *genome,