cf3880c50c550e4deb61c9664f4f994e13ab6dd8
max
  Mon Aug 17 08:05:58 2026 -0700
hgc/hgTracks: fix three items from the v502 code review, refs #38106

Shared BLAT alignment links (hgc g=htcBlatAlign) drew the page and then
exit(0), which skips main's cartCheckout, so the loaded session was never
written back and the recipient's cart ended up nearly empty. Add
cartCheckout(&cart) before all four exit(0) calls that follow webEndGb(),
including the two early error returns.

squishCodonFont() decided FreeType was active with a looser test than
maybeNewFonts(), missing the requirement that the font name match a row in
freeTypeFonts[]; when they disagreed the bitmap engine got a cell height it
cannot render. Factor the engine decision into freeTypeFontActive() and use
it in both places.

Query name, chrom and a hub's organism string went raw into single-quoted JS
string literals and page titles on the modern alignment page; the shared-link
path reads the query name back out of a bigPsl, so it is not covered by
hgBlat's whitelist. javaScriptLiteralEncode the JS arguments and htmlEncode
the HTML labels.

Also add "u"/"s" (the shared-link session selectors) to hgc excludeVars so
they are not left in the reader's cart.

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 122766238f4..871c202ec6d 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -4330,38 +4330,34 @@
     return FALSE;
 if (retColor != NULL)
     *retColor = spec->color;
 if (retWholeItem != NULL)
     *retWholeItem = spec->wholeItem;
 return TRUE;
 }
 
 static MgFont *squishCodonFont()
 /* Pick a small-but-readable amino-acid font for the short squish rows, where the
  * full track font is taller than the row and gets clipped.  We want ~9px.  The
  * built-in fonts jump from 8px straight to 11px, but the FreeType engine can
  * render an in-between size, so use a 9px font there; under the GEM bitmap engine
  * (which cannot fake a size) fall back to the size-8 font. */
 {
-boolean freetypeActive =
-#ifdef USE_FREETYPE
-    sameString(cfgOptionDefault("freeType", "on"), "on")
-#else
-    FALSE
-#endif
-    && differentString(tl.textFont, "Bitmap");
-if (freetypeActive)
+/* Use the same predicate maybeNewFonts() uses to switch engines: freeType on, textFont not
+ * "Bitmap", and the font name known to freeTypeFonts[].  A looser test can send mgFontForCellHeight
+ * a size the bitmap engine cannot render (see the warning in lib/memgfx.c). */
+if (freeTypeFontActive())
     return mgFontForCellHeight(10);   // getFontCorrection(10) renders ~9px
 return mgFontForSize("8");
 }
 
 void linkedFeaturesDrawAt(struct track *tg, void *item,
                           struct hvGfx *hvg, int xOff, int y, double scale,
                           MgFont *font, Color color, enum trackVisibility vis)
 /* Draw a single simple bed item at position. */
 {
 struct linkedFeatures *lf = item;
 struct simpleFeature *sf, *components;
 int heightPer = tg->heightPer;
 int x1,x2;
 int shortOff = heightPer/4;
 int shortHeight = heightPer - 2*shortOff;