a6a7e658e255ff09b7128f43b84de3a5ad1d74d2
braney
Tue Aug 25 09:28:08 2026 -0700
cart.c: resolve a GenArk db= again after a session load, refs #38184
A URL with both db=GCF_... and a session load failed with an unknown
database error. fixUpDb turns db=GCF_... into genome= plus hubUrl=, but
the session load empties the cart and then restores the raw CGI
variables, so the bare accession reached hDbConnect.
Split the GenArk part of fixUpDb into resolveGenarkDb and call that once
more after the session-load block. Only the rewrite runs there, not the
bad-database errAbort, so a session that carries a retired db fails the
way it does now. Covers hgS_doLoadUrl and hgS_doOtherUser.
diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index f077aae2aa2..cc42d06d0e2 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -1621,55 +1621,66 @@
struct trackDb *tdb = hTrackDb(db);
for(; tdb; tdb = tdb->next)
{
struct trackDb *parent = tdb->parent;
if (parent && parent->isShow)
hideIfNotInCart(cart, parent->track);
if (tdb->visibility != tvHide)
hideIfNotInCart(cart, tdb->track);
}
// Don't do this again until someone sets this variable,
// presumably on session load.
cartRemove(cart, CART_HAS_DEFAULT_VISIBILITY);
}
-static void fixUpDb(struct cart *cart)
-// we want to load Genark hubs or error out if db is not available
+static boolean resolveGenarkDb(struct cart *cart)
+/* If db names a Genark assembly, turn it into the genome and hubUrl variables that
+ * connect that Genark hub, and return TRUE. Otherwise leave the cart alone and
+ * return FALSE. */
{
char *db = cartOptionalString(cart,"db");
if ((db == NULL) || startsWith("hub_", db) || sameString("0", db))
- return;
-else
- {
+ return FALSE;
+
char *url = genarkUrl(db);
- if (url != NULL)
- {
+if (url == NULL)
+ return FALSE;
+
cartSetString(cart, "genome", db);
cartAddString(cart, "hubUrl", url);
cartRemove(cart, "db");
+return TRUE;
}
- else if (!hDbIsActive(db))
+
+static void fixUpDb(struct cart *cart)
+// we want to load Genark hubs or error out if db is not available
+{
+char *db = cartOptionalString(cart,"db");
+
+if ((db == NULL) || startsWith("hub_", db) || sameString("0", db))
+ return;
+
+if (!resolveGenarkDb(cart) && !hDbIsActive(db))
errAbort("Can not find database '%s'.
"
"You can search for the genome %s in "
"the list of NCBI/INSDC assemblies, then click 'request' when you have found the right assembly "
"and enter your email address. We will then make a genome browser and get back to you within a few days.",
db, db, db);
}
-}
boolean isValidToken(char *token)
/* send https req to cloudflare, check if the token that we got from the captcha is really the one made by cloudflare */
{
char *url = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
char *secret = cfgVal("cloudFlareSecretKey");
if (!secret)
errAbort("'cloudFlareSecretKey' must be set in hg.conf if cloudflare is activated in hg.conf");
char data[3000]; // cloudflare token is at most 2000 bytes
safef(data, sizeof(data), "secret=%s&response=%s", secret, token);
char *reply = curlPostUrl(url, data);
boolean res = strstr(reply, "\"success\":true") != NULL;
freez(&reply);
@@ -1933,32 +1944,39 @@
{
warn("Unable to load session file: %s", dyMessage->string);
}
didSessionLoad = ok;
dyStringFree(&dyMessage);
}
}
#endif /* GBROWSE */
/* wire up the assembly hubs so we can operate without sql */
setUdcOptions(cart);
if (cartVarExists(cart, hgHubDoDisconnect))
doDisconnectHub(cart);
if (didSessionLoad)
+ {
cartCopyLocalHubs(cart);
+ // Loading a session empties the cart and then puts the CGI variables back, which
+ // undoes the work fixUpDb did above. A Genark accession in db= has to be turned
+ // back into a genome and a hubUrl before we connect the hubs. refs #38184
+ resolveGenarkDb(cart);
+ }
+
char *newDatabase = hubConnectLoadHubs(cart);
if (newDatabase != NULL)
{
char *cartDb = cartOptionalString(cart, "db");
if ((cartDb == NULL) || differentString(cartDb, newDatabase))
{
// this is some magic to use the defaultPosition and reset cart variables
if (oldVars)
{
struct hashEl *hel;
if ((hel = hashLookup(oldVars,"db")) != NULL)
hel->val = "none";
else