43c1ad49687da203d0be65ce7b2bc2c42cf5543a angie Fri Jul 1 16:31:15 2011 -0700 Feature #986 (VCF): keys can have <>'s, so html encode them for display. diff --git src/hg/hgc/vcfClick.c src/hg/hgc/vcfClick.c index 2fa75f4..4a1565d 100644 --- src/hg/hgc/vcfClick.c +++ src/hg/hgc/vcfClick.c @@ -1,53 +1,54 @@ /* vcfTrack -- handlers for Variant Call Format data. */ #ifdef USE_TABIX #include "common.h" #include "dystring.h" #include "errCatch.h" #include "hCommon.h" #include "hdb.h" #include "hgc.h" +#include "htmshell.h" #if (defined USE_TABIX && defined KNETFILE_HOOKS) #include "knetUdc.h" #include "udc.h" #endif//def USE_TABIX && KNETFILE_HOOKS #include "pgSnp.h" #include "trashDir.h" #include "vcf.h" #define NA "<em>n/a</em>" static void printListWithDescriptions(struct vcfFile *vcff, char *str, char *sep, struct vcfInfoDef *infoDefs) /* Given a VCF field, its separator char and a list of vcfInfoDefs, print out a list * of values with descriptions if descriptions are available. */ { char *copy = cloneString(str); char *words[256]; int i, wordCount = chopString(copy, sep, words, ArraySize(words)); for (i = 0; i < wordCount; i++) { if (i > 0) printf(", "); char *key = words[i]; const struct vcfInfoDef *def = vcfInfoDefForKey(vcff, key); if (def != NULL) - printf("%s (%s)", key, def->description); + printf("%s (%s)", htmlEncode(key), def->description); else - printf("%s", key); + printf("%s", htmlEncode(key)); } printf("<BR>\n"); } static void vcfAltAlleleDetails(struct vcfRecord *rec) /* If VCF header specifies any symbolic alternate alleles, pull in descriptions. */ { printf("<B>Alternate allele(s):</B> "); if (sameString(rec->alt, ".")) { printf(NA"<BR>\n"); return; } struct vcfFile *vcff = rec->file; printListWithDescriptions(vcff, rec->alt, ",", vcff->altDefs);