ae1b9adc9d85808683118f771703aeb8970306bf braney Sat Aug 22 10:19:03 2026 -0700 hubApi: add X-Content-Type-Options: nosniff to responses, refs #38163 Set the nosniff header ahead of the Content-Type on every hubApi output path (JSON, text, and html), so responses declare their type explicitly. diff --git src/hg/hubApi/blat.c src/hg/hubApi/blat.c index 4dfe07a55a9..251a39a460e 100644 --- src/hg/hubApi/blat.c +++ src/hg/hubApi/blat.c @@ -124,45 +124,47 @@ toLowerN(seq->dna, seq->size); subChar(seq->dna, 'u', 't'); } } if (seqList != NULL && seqList->name[0] == 0) { freeMem(seqList->name); seqList->name = cloneString("YourSeq"); } } static void writePslOutput(struct psl *pslList, struct blatType *bt) /* PSL text output path (output=psl). */ { hPrintDisable(); +puts("X-Content-Type-Options: nosniff"); puts("Content-Type:text/plain\n"); pslxWriteHead(stdout, bt->qType, bt->tType); struct psl *psl; int n = 0; for (psl = pslList; psl != NULL && n < maxItemsOutput; psl = psl->next, ++n) pslTabOut(psl, stdout); } static void writeLegacyJsonOutput(struct psl *pslList, char *db) /* Byte-for-byte the same JSON shape hgBlat?output=json emits: a top-level * object with "track":"blat", "genome", a "fields" header array, and "blat" * as an array of arrays (one row per PSL). * Triggered by format=hgblat or jsonOutputArrays=1. */ { hPrintDisable(); +puts("X-Content-Type-Options: nosniff"); puts("Content-Type:text/plain\n"); pslWriteAllJson(pslList, stdout, db, TRUE); } static void writePslAsObject(struct jsonWrite *jw, struct psl *psl) /* Write one PSL hit as a JSON object with named keys. */ { int b; jsonWriteObjectStart(jw, NULL); jsonWriteNumber(jw, "matches", psl->match); jsonWriteNumber(jw, "misMatches", psl->misMatch); jsonWriteNumber(jw, "repMatches", psl->repMatch); jsonWriteNumber(jw, "nCount", psl->nCount); jsonWriteNumber(jw, "qNumInsert", psl->qNumInsert); jsonWriteNumber(jw, "qBaseInsert", psl->qBaseInsert);