979a6409ad7d171eeb48d44b5a0d2cba0d304059 hiram Thu Jun 27 13:43:01 2019 -0700 checking for supported table and avoid container tracks on requests refs #23589 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 618b1fa..a41481e 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -51,32 +51,31 @@ static struct hash *oldVars = NULL; static struct hash *trackCounter = NULL; static long totalTracks = 0; static boolean allTrackSettings = FALSE; /* checkbox setting */ static char **shortLabels = NULL; /* public hub short labels in array */ static int publicHubCount = 0; static char *defaultHub = "Plants"; static char *defaultDb = "ce11"; long enteredMainTime = 0; /* will become = clock1000() on entry */ /* to allow calculation of when to bail out, taking too long */ static long timeOutSeconds = 100; static boolean timedOut = FALSE; static char *urlPrefix = ""; /* initalized to support self references */ /* supportedTypes will be initialized to a known supported set */ -static struct slName *supportedTypes = NULL; - +struct slName *supportedTypes = NULL; static void initSupportedTypes() /* initalize the list of supported track types */ { struct slName *el = newSlName("bed"); slAddHead(&supportedTypes, el); el = newSlName("wig"); slAddHead(&supportedTypes, el); el = newSlName("broadPeak"); slAddHead(&supportedTypes, el); el = newSlName("narrowPeak"); slAddHead(&supportedTypes, el); el = newSlName("bigBed"); slAddHead(&supportedTypes, el); el = newSlName("bigWig"); @@ -90,49 +89,31 @@ el = newSlName("psl"); slAddHead(&supportedTypes, el); el = newSlName("rmsk"); slAddHead(&supportedTypes, el); el = newSlName("bigPsl"); slAddHead(&supportedTypes, el); // el = newSlName("bigBarChart"); // slAddHead(&supportedTypes, el); // el = newSlName("bigInteract"); // slAddHead(&supportedTypes, el); // el = newSlName("bigMaf"); // slAddHead(&supportedTypes, el); // el = newSlName("bigChain"); // slAddHead(&supportedTypes, el); slNameSort(&supportedTypes); -} - -static boolean isSupportedType(char *type) -/* is given type in the supportedTypes list ? */ -{ -boolean ret = FALSE; -if (startsWith("wigMaf", type)) /* not wigMaf at this time */ - return ret; -struct slName *el; -for (el = supportedTypes; el; el = el->next) - { - if (startsWith(el->name, type)) - { - ret = TRUE; - break; - } - } -return ret; -} +} /* static void initSupportedTypes() */ static int publicHubCmpCase(const void *va, const void *vb) /* Compare two shortLabels, ignore case. */ { const struct hubPublic *a = *((struct hubPublic **)va); const struct hubPublic *b = *((struct hubPublic **)vb); return strcasecmp(a->shortLabel, b->shortLabel); } static void publicHubSortCase(struct hubPublic **pList) /* Sort slName list, ignore case. */ { slSort(pList, publicHubCmpCase); } @@ -1301,31 +1282,30 @@ static void doMiddle(struct cart *theCart) /* Set up globals and make web page */ { cart = theCart; // measureTiming = isNotEmpty(cartOptionalString(cart, "measureTiming")); char *database = NULL; char *genome = NULL; if (measureTiming) startProcessTiming(); cgiVarSet("ignoreCookie", "1"); getDbAndGenome(cart, &database, &genome, oldVars); initGenbankTableNames(database); -initSupportedTypes(); initUrlPrefix(); trackLeavesOnly = cartUsualBoolean(cart, "trackLeavesOnly", trackLeavesOnly); jsonOutputArrays = cartUsualBoolean(cart, "jsonOutputArrays", jsonOutputArrays); char *pathInfo = getenv("PATH_INFO"); /* nothing on incoming path, then display the WEB page instead */ if (sameOk("/",pathInfo)) pathInfo = NULL; (void) hubPublicDbLoadAll(); webStartJWest(cart, database, "Genome Browser API"); // webStartGbNoBanner(cart, database, "UCSC JSON API interface"); // webStartGbOptionalBanner(cart, database, "UCSC JSON API interface", TRUE, FALSE); @@ -1556,30 +1536,32 @@ { sleep1000(botDelay); hogExit(); return 0; } sleep1000(botDelay); } setGlobalCgiVars(); int timeout = cgiOptionalInt("udcTimeout", 300); if (udcCacheTimeout() < timeout) udcSetCacheTimeout(timeout); knetUdcInstall(); +initSupportedTypes(); + char *pathInfo = getenv("PATH_INFO"); if (isNotEmpty(pathInfo)) /* can get to this immediately, no cart needed */ apiRequest(pathInfo); else { char *allowApiHtml = cfgOptionDefault("hubApi.allowHtml", "off"); if (sameWord("on", allowApiHtml)) { trackCounter = hashNew(0); cartEmptyShellNoContent(doMiddle, hUserCookie(), excludeVars, oldVars); } else redirectToHelp(); } cgiExitTime("hubApi", enteredMainTime);