f247b79b61ca172b3146284594b97c848db4c8bf braney Wed Sep 2 11:20:43 2026 -0700 hgSession, hgGenome: tighten handling of an uploaded file's name, refs #38172 Both CGIs print the name that arrives with an upload straight into the page. hgSession prints it in four of its load messages, so encode it once where it is read; the sibling URL message three lines above already did the same for the URL. hgGenome puts it in a quoted attribute, which wants attributeEncode. Raised in the v503 Preview II code review. diff --git src/hg/hgGenome/upload.c src/hg/hgGenome/upload.c index 879da8ec46a..c97c97f8bf9 100644 --- src/hg/hgGenome/upload.c +++ src/hg/hgGenome/upload.c @@ -1,248 +1,250 @@ /* Upload - put up upload pages and sub-pages. */ /* Copyright (C) 2011 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "ra.h" #include "portable.h" #include "cheapcgi.h" #include "localmem.h" #include "cart.h" #include "web.h" #include "chromInfo.h" #include "chromGraph.h" #include "chromGraphFactory.h" #include "errCatch.h" #include "hPrint.h" #include "customTrack.h" #include "hgGenome.h" #include "trashDir.h" +#include "htmshell.h" static char *markerNames[] = { cgfMarkerGuess, cgfMarkerGenomic, cgfMarkerSts, cgfMarkerSnp, // cgfMarkerAffy100, cgfMarkerAffy500, cgfMarkerAffy6, cgfMarkerAffy6SV, cgfMarkerHumanHap300, cgfMarkerHumanHap550, cgfMarkerHumanHap650, cgfMarkerHumanHap1M, cgfMarkerAgilentCgh244A, }; static char *formatNames[] = { cgfFormatGuess, cgfFormatTab, cgfFormatComma, cgfFormatSpace, }; static char *colLabelNames[] = { cgfColLabelGuess, cgfColLabelNumbered, cgfColLabelFirstRow, }; void uploadPage() /* Put up initial upload page. */ { char *oldFileName = cartUsualString(cart, hggUploadFile "__filename", ""); cartWebStart(cart, database, "Upload Data to Genome Graphs"); hPrintf("
"); cartSaveSession(cart); hPrintf("name of data set: "); cartMakeTextVar(cart, hggDataSetName, "", 16); hPrintf("
"); hPrintf("description: "); cartMakeTextVar(cart, hggDataSetDescription, "", 64); hPrintf("
\n"); hPrintf("file format: "); cgiMakeDropList(hggFormatType, formatNames, ArraySize(formatNames), cartUsualString(cart, hggFormatType, formatNames[0])); hPrintf("
\n"); hPrintf(" markers are: "); cgiMakeDropList(hggMarkerType, markerNames, ArraySize(markerNames), cartUsualString(cart, hggMarkerType, markerNames[0])); hPrintf("
\n"); hPrintf(" column labels: "); cgiMakeDropList(hggColumnLabels, colLabelNames, ArraySize(colLabelNames), cartUsualString(cart, hggColumnLabels, colLabelNames[0])); hPrintf("
\n"); hPrintf("display min value: "); cartMakeTextVar(cart, hggMinVal, "", 5); hPrintf(" max value: "); cartMakeTextVar(cart, hggMaxVal, "", 5); hPrintf("
\n"); hPrintf("label values: "); cartMakeTextVar(cart, hggLabelVals, "", 32); hPrintf("
\n"); hPrintf("draw connecting lines between markers separated by up to "); cartMakeIntVar(cart, hggMaxGapToFill, 25000000, 8); hPrintf(" bases.
"); hPrintf("
\n"); +/* oldFileName arrives with the upload and lands inside a quoted attribute. */ hPrintf("file name: ", hggUploadFile, - oldFileName); + attributeEncode(oldFileName)); hPrintf("
\n"); hPrintf(" or
\n"); hPrintf("Paste URLs or data:
"); cgiMakeTextArea(hggUploadUrl, "", 7, 73); hPrintf("
\n"); hPrintf("
\n"); cgiMakeButton(hggSubmitUpload, "submit"); hPrintf("
\n"); hPrintf("Note: If you are uploading more than one data set please give them "); hPrintf("different names. Only the most recent data set of a given name is "); hPrintf("kept. Otherwise data sets will be kept for at least 48 hours from "); hPrintf("last use. After that time you may have to upload them again."); /* Put up section that describes file formats. */ webNewSection("Upload file formats"); hPrintf("%s", "

The upload file is a table in some format. In all formats there is " "a single line for each marker. " "Each line starts with information on the marker, and ends with " "the numerical values associated with that marker. The exact format " "of the line depends on what is selected from the markers drop " "down menu. If this is chromosome base then the line will " "contain the tab or space-separated fields: chromosome, position, " "and value(s). The first base in a chromosome is considered position 0. " "An example chromosome base type line is:

\n"
 "chrX 100000 1.23\n"
 "
The lines for other marker types contain two fields: " "marker and value(s). For dbSNP rsID's an example is:
\n"
 "rs10218492 0.384\n"
 "
" "

" "The file can contain multiple value fields. In this case a " "separate graph will be available for each value column in the input " "table. It's a " "good idea to set the display min/max values above if you want the " "graphs to share the same scale." "

" ); webNewSection("Using the upload page"); hPrintf( "To upload a file in any of the supported formats, " "locate the file on your computer using the controls next to file name, " "or supply a URL to the data, " "and then submit. The other controls on this form are optional, though " "filling them out will sometimes enhance the display. In general " "the controls that default to best guess can be left alone, " "since the guess is almost always correct. The controls for display min and " "max values and connecting lines can be set later via the configuration " "page as well. Here is a description of each control." "