d0964dccfb4e1519574990aa210b953ace4c8851 chmalee Thu Mar 26 14:36:34 2020 -0700 Fixing where I inadvertently deleted a comma in the last commit, and fixing some htmlEncoding errors after code review feedback, refs #25221 diff --git src/hg/utils/hubCheck/hubCheck.c src/hg/utils/hubCheck/hubCheck.c index 38291b4..7f7aa4f 100644 --- src/hg/utils/hubCheck/hubCheck.c +++ src/hg/utils/hubCheck/hubCheck.c @@ -454,72 +454,72 @@ dyStringPrintf(errors, "Setting '%s' is level '%s'\n", setting, hubSetting->level); retVal = 1; } freez(&checkLevel); } return retVal; } char *makeFolderObjectString(char *id, char *text, char *parent, char *title, boolean children, boolean openFolder) /* Construct a folder item for one of the jstree arrays */ { struct dyString *folderString = dyStringNew(0); dyStringPrintf(folderString, "{icon: '../../images/folderC.png', id: '%s', " "text:\"%s\", parent:'%s'," "li_attr:{title:'%s'}, children:%s, state: {opened: %s}}", - id, text, parent, title, children ? "true" : "false", openFolder ? "true" : "false"); + htmlEncode(id), text, htmlEncode(parent), title, children ? "true" : "false", openFolder ? "true" : "false"); return dyStringCannibalize(&folderString); } char *makeChildObjectString(char *id, char *title, char *shortLabel, char *longLabel, char *color, char *name, char *text, char *parent) /* Construct a single child item for one of the jstree arrays */ { struct dyString *item = dyStringNew(0); dyStringPrintf(item, "{icon: 'fa fa-plus', id:'%s', li_attr:{class: 'hubError', title: '%s', " "shortLabel: '%s', longLabel: '%s', color: '%s', name:'%s'}, " "text:'%s', parent: '%s', state: {opened: true}}", - id, title, shortLabel, longLabel, color, name, replaceChars(text, "'", "\\'"), parent); + htmlEncode(id), title, shortLabel, longLabel, color, name, replaceChars(text, "'", "\\'"), htmlEncode(parent)); return dyStringCannibalize(&item); } void hubErr(struct dyString *errors, char *message, struct trackHub *hub, boolean doHtml) /* Construct the right javascript for the jstree for a top level hub.txt error. */ { if (!doHtml) dyStringPrintf(errors, "%s", message); else { char *sl; char *strippedMessage = NULL; static int count = 0; // force a unique id for the jstree object char id[512]; //TODO: Choose better default labels if (hub && hub->shortLabel != NULL) { sl = hub->shortLabel; } else sl = "Hub Error"; if (message) strippedMessage = cloneString(message); stripChar(strippedMessage, '\n'); safef(id, sizeof(id), "%s%d", sl, count); // make the error message - dyStringPrintf(errors, "trackData['%s'] = [%s];\n", sl, - makeChildObjectString(id, "Hub Error", sl, sl, "#550073", sl, strippedMessage, sl)); + dyStringPrintf(errors, "trackData['%s'] = [%s];\n", htmlEncode(sl), + makeChildObjectString(id, "Hub Error", htmlEncode(sl), htmlEncode(sl), "#550073", htmlEncode(sl), strippedMessage, sl)); count++; } } void genomeErr(struct dyString *errors, char *message, struct trackHub *hub, struct trackHubGenome *genome, boolean doHtml) /* Construct the right javascript for the jstree for a top-level genomes.txt error or * error opening a trackDb.txt file */ { if (!doHtml) dyStringPrintf(errors, "%s", message); else { static int count = 0; // forces unique ID's which the jstree object needs @@ -926,37 +926,37 @@ if (descUrl == NULL) warn("warning: missing hub overview descripton page (descriptionUrl setting)"); else if ((!hasProtocol(descUrl) && !udcExists(descUrl)) || netUrlHead(descUrl, NULL) < 0) warn("warning: %s descriptionUrl setting does not exist", hub->descriptionUrl); } errCatchEnd(errCatch); if (errCatch->gotError || errCatch->gotWarning) { retVal = 1; hubErr(hubErrors, errCatch->message->string, hub, options->htmlOut); if (options->htmlOut) { if (hub && hub->shortLabel) { - dyStringPrintf(errors, "trackData['#'] = [%s", + dyStringPrintf(errors, "trackData['#'] = [%s,", makeFolderObjectString(hub->shortLabel, "Hub Errors", "#", "Click to open node", TRUE, TRUE)); } else { - dyStringPrintf(errors, "trackData['#'] = [%s", + dyStringPrintf(errors, "trackData['#'] = [%s,", makeFolderObjectString("Hub Error", "Hub Errors", "#", "Click to open node", TRUE, TRUE)); } } } errCatchFree(&errCatch); if (hub == NULL) { // the reason we couldn't close the array in the previous block is because // there may be non-fatal errors and we still want to keep trying to check // the genomes settings, which need to be children of the root '#' node. // Here we are at a fatal error so we can close the array and return if (options->htmlOut) dyStringPrintf(errors, "];\n%s", dyStringCannibalize(&hubErrors));