a53b9958fa734f73aeffb9ddfe2fbad1ca65f90c galt Mon Jan 30 16:18:41 2017 -0800 Check-in of CSP2 Content-Security-Policy work. All C-language CGIs should now support CSP2 in browser to stop major forms of XSS javascript injection. Javascript on pages is gathered together, and then emitted in a single script block at the end with a nonce that tells the browser, this is js that we generated instead of being injected by a hacker. Both inline script from script blocks and inline js event handlers had to be pulled out and separated. You will not see js sprinkled through-out the page now. Older browsers that support CSP1 or that do not understand CSP at all will still work, just without protection. External js libraries loaded at runtime need to be added to the CSP policy header in src/lib/htmshell.c. diff --git src/hg/lib/fileUi.c src/hg/lib/fileUi.c index 2481dc0..a730971 100644 --- src/hg/lib/fileUi.c +++ src/hg/lib/fileUi.c @@ -547,31 +547,31 @@ slNameFree(&term); } // If there is more than one val for this var then create filterBy box for it if (slCount(tagLabelPairs) > 1) { // should have a list sorted on the label enum cvDataType eCvDataType = cvDataType(var); if (eCvDataType == cvInteger) slPairValAtoiSort(&tagLabelPairs); else slPairValSortCase(&tagLabelPairs); char extraClasses[256]; safef(extraClasses,sizeof extraClasses,"filterTable %s",var); char *dropDownHtml = cgiMakeMultiSelectDropList(var,tagLabelPairs,NULL,"All", - extraClasses,"onchange='filterTable.filter(this);' style='font-size:.9em;'"); + extraClasses, "change", "filterTable.filter(this);", "font-size:.9em;", NULL); // Note filterBox has classes: filterBy & {var} if (dropDownHtml) { dyStringPrintf(dyFilters, "\n%s:
\n%s \n", labelWithVocabLink(var,sortOrder->title[sIx],tagLabelPairs,TRUE), dropDownHtml); // TRUE were sending tags, not values freeMem(dropDownHtml); count++; if (sIx < 32) // avoid bit overflow but 32 filterBoxes? I don't think so filterableBits |= (0x1<<(sIx)); } } if (tagLabelPairs != NULL) slPairFreeValsAndList(&tagLabelPairs); @@ -632,30 +632,31 @@ printf("
• supplemental materials - " "any related files provided by the laboratory.\n", server,db,ENCODE_DCC_DOWNLOADS, tdb->track, subDir); } } static int filesPrintTable(char *db, struct trackDb *parentTdb, struct fileDb *fileList, sortOrder_t *sortOrder,int filterable) // Prints filesList as a sortable table. Returns count { if (timeIt) uglyTime("Start table"); // Table class=sortable int columnCount = 0; +int butCount = 0; int restrictedColumn = 0; char *nowrap = (sortOrder->setting != NULL ? " nowrap":""); // Sort order trackDb setting found so rely on
in titles for wrapping printf("\n"); printf("\n"); printf("\n"); printf("",(filterable != 0) ?" class='filterable'":""); // Download button printf("\n"); // Each of the pulled out mdb vars if (sortOrder) { for (ix=0;ixcount;ix++) { if (sameString("fileSize",sortOrder->column[ix])) @@ -836,32 +841,32 @@ (restrictedColumn > 1 ? (restrictedColumn - 1) : columnCount)); // Total if (filesCount > 5) printf("%d files",filesCount); // Restriction policy link in later column? if (restrictedColumn > 1) printf("\n"); printf("
 "); int filesCount = slCount(fileList); if (filesCount > 5) printf("%d files",filesCount); // NOTE: This could be done to preserve sort order in cart. // However hgFileUi would need form OR changes would need to be ajaxed over // AND hgsid would be needed. //if (sortOrder) @@ -711,33 +712,37 @@ oneFile->mdb->next = NULL; // mdbs were in list for generating sortOrder, char *field = NULL; // but list no longer needed printf("
"); if (parentTdb) field = parentTdb->track; else { field = cloneString(mdbObjFindValue(oneFile->mdb,MDB_VAR_COMPOSITE)); mdbObjRemoveOneVar(oneFile->mdb,MDB_VAR_COMPOSITE,NULL); } assert(field != NULL); - printf("", - server,db,ENCODE_DCC_DOWNLOADS, field, subDir, oneFile->fileName, oneFile->fileName); + char id[256]; + safef(id, sizeof id, "ftpBut_%d", butCount++); + printf("", id, oneFile->fileName); + char javascript[1024]; + safef(javascript, sizeof javascript, "window.location='http://%s/goldenPath/%s/%s/%s%s/%s';" + ,server,db,ENCODE_DCC_DOWNLOADS, field, subDir, oneFile->fileName); + jsOnEventById("click", id, javascript); #define SHOW_FOLDER_FRO_COMPOSITE_DOWNLOADS #ifdef SHOW_FOLDER_FRO_COMPOSITE_DOWNLOADS if (parentTdb == NULL) printf("  ", db,field,field); #endif///def SHOW_FOLDER_FRO_COMPOSITE_DOWNLOADS printf("" "Restriction Policy", columnCount,ENCODE_DATA_RELEASE_POLICY); printf("
\n"); if (parentTdb == NULL) - printf("\n"); + jsInline("{$(document).ready(function() {" + "sortTable.initialize($('table.sortable')[0],true,true);});}\n"); if (timeIt) uglyTime("Finished table"); return filesCount; } static int filesFindInDir(char *db, struct mdbObj **pmdbFiles, struct fileDb **pFileList, char *fileType, int limit, boolean *exceededLimit, boolean *isUnrestricted) // Prints list of files in downloads directories matching mdb search terms. Returns count { int fileCount = 0; if (isUnrestricted != NULL) *isUnrestricted = TRUE;