e6b0dc7877ae4b24f56682885e03263fd2da3582
braney
Tue Aug 18 11:37:04 2026 -0700
lib, hgc: encode barChart, BAM and VCF detail text consistently, refs #38123
diff --git src/hg/lib/barChartUi.c src/hg/lib/barChartUi.c
index 3bcbecf4071..70410a14e4c 100644
--- src/hg/lib/barChartUi.c
+++ src/hg/lib/barChartUi.c
@@ -1,90 +1,93 @@
/* Bar chart track controls */
/* Copyright (C) 2015 The Regents of the University of California
* See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
#include "cheapcgi.h"
+#include "htmshell.h"
#include "cart.h"
#include "net.h"
#include "errCatch.h"
#include "web.h"
#include "hui.h"
#include "trackDb.h"
#include "jsHelper.h"
#include "hCommon.h"
#include "rainbow.h"
#include "htmlColor.h"
#include "barChartCategory.h"
#include "barChartUi.h"
#include "facetedTable.h"
#include "tablesTables.h"
/* Restrict features on right-click (popup) version */
static boolean isPopup = FALSE;
/* Convenience functions for category filter controls */
char *makeCategoryLabel(struct barChartCategory *categ)
/* Display category color and label */
{
-char buf[256];
-safef(buf, sizeof(buf), "
"
+// the label comes from the barChartBars setting, which a track hub controls, escape it.
+// A dyString rather than a fixed buffer, since escaping can grow a long label past 256 bytes.
+struct dyString *dy = dyStringNew(256);
+dyStringPrintf(dy, "
\n", htmlEncode(title));
int count = slCount(selects);
struct categorySelect **categArray;
AllocArray(categArray, count);
int i=0;
struct categorySelect *sel;
for (i=0, sel = selects; sel != NULL; sel = sel->next, i++)
categArray[i] = sel;
int col=0;
int row=0;
int tableColumns=1;
for (i=0; i=count)
{
printf("
");
row++;
col = 0;
}
j = row + col*(count/tableColumns+1);
if (!isPopup)
{
printf("
" "
%s
\n",
- name, categArray[j]->name, categArray[j]->checked ? "checked" : "",
- categArray[j]->label);
+ name, htmlEncode(categArray[j]->name), categArray[j]->checked ? "checked" : "",
+ categArray[j]->label); // label is escaped html already, from makeCategoryLabel
}
col++;
}
if ((i % tableColumns) != 0)
while ((i++ % tableColumns) != 0)
printf("
");
barChartUiLogTransform(cart, track, tdb);
/* Viewing limits max. This control is disabled if log transform is selected */
// construct class so JS can toggle
puts(" ");
barChartUiViewLimits(cart, track, tdb);
puts("