ee7ab212a65d53edcc6e18e4db6536a7220b7842 galt Thu Jan 20 20:58:39 2011 -0800 fixing a bug with chewed up original input, and added checking for problems caused by users accidentally pasting ct data into the html documentation field diff --git src/hg/lib/customTrack.c src/hg/lib/customTrack.c index a3f3075..ec292dd 100644 --- src/hg/lib/customTrack.c +++ src/hg/lib/customTrack.c @@ -730,38 +730,49 @@ { if (customTrackIsCompressed(docFileName)) html = prepCompressedFile(cart, docFileName, CT_CUSTOM_DOC_FILE_BIN_VAR, CT_CUSTOM_DOC_FILE_VAR); else { /* unreadable file */ struct dyString *ds = dyStringNew(0); dyStringPrintf(ds, "Can't read doc file: %s", docFileName); err = dyStringCannibalize(&ds); customText = NULL; } } else html = cartUsualString(cart, CT_CUSTOM_DOC_TEXT_VAR, ""); -html = customDocParse(html); +html = cloneString(html); /* do not let original cart var get eaten up */ +html = customDocParse(html); /* this will chew up the input string */ if(html != NULL) { char *tmp = html; html = jsStripJavascript(html); freeMem(tmp); } +if ((strlen(html) > 50*1024) || startsWith("track ", html) || startsWith("browser ", html)) + { + err = cloneString( + "Optional track documentation appears to be either too large (greater than 50k) or it starts with a track or browser line. " + "This is usually an indication that the data has been accidentally put into the documentation field. " + "Only html documentation is intended for this field. " + "Please correct and re-submit."); + customText = NULL; + } + struct customTrack *newCts = NULL, *ct = NULL; if (isNotEmpty(customText)) { /* protect against format errors in input from user */ struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { newCts = customFactoryParse(genomeDb, customText, FALSE, &browserLines); if (html) { for (ct = newCts; ct != NULL; ct = ct->next) if (!ctHtmlUrl(ct)) ct->tdb->html = cloneString(html); freez(&html); }