080a160c7b9595d516c9c70e83689a09b60839d0
galt
  Mon Jun 3 12:16:53 2013 -0700
fix SQL Injection
diff --git src/hg/lib/hapmapPrimateAlleles.c src/hg/lib/hapmapPrimateAlleles.c
index fbbee97..6f9148c 100644
--- src/hg/lib/hapmapPrimateAlleles.c
+++ src/hg/lib/hapmapPrimateAlleles.c
@@ -113,80 +113,39 @@
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = hapmapPrimateAllelesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void hapmapPrimateAllelesSaveToDb(struct sqlConnection *conn, struct hapmapPrimateAlleles *el, char *tableName, int updateSize)
 /* Save hapmapPrimateAlleles as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
- * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
- * For example "autosql's features include" --> "autosql\'s features include" 
- * If worried about this use hapmapPrimateAllelesSaveToDbEscaped() */
+ * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
 {
 struct dyString *update = newDyString(updateSize);
-dyStringPrintf(update, "insert into %s values ( '%s',%u,%u,'%s',%u,'%c','%c','%c','%s',%u,'%c','%s',%u,'%s',%u,'%c','%s',%u)", 
+sqlDyStringPrintf(update, "insert into %s values ( '%s',%u,%u,'%s',%u,'%c','%c','%c','%s',%u,'%c','%s',%u,'%s',%u,'%c','%s',%u)", 
 	tableName,  el->chrom,  el->chromStart,  el->chromEnd,  el->name,  el->score,  el->strand,  el->refAllele,  el->otherAllele,  el->chimpChrom,  el->chimpPos,  el->chimpStrand,  el->chimpAllele,  el->chimpQual,  el->rhesusChrom,  el->rhesusPos,  el->rhesusStrand,  el->rhesusAllele,  el->rhesusQual);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
-void hapmapPrimateAllelesSaveToDbEscaped(struct sqlConnection *conn, struct hapmapPrimateAlleles *el, char *tableName, int updateSize)
-/* Save hapmapPrimateAlleles as a row to the table specified by tableName. 
- * As blob fields may be arbitrary size updateSize specifies the approx size.
- * of a string that would contain the entire query. Automatically 
- * escapes all simple strings (not arrays of string) but may be slower than hapmapPrimateAllelesSaveToDb().
- * For example automatically copies and converts: 
- * "autosql's features include" --> "autosql\'s features include" 
- * before inserting into database. */ 
-{
-struct dyString *update = newDyString(updateSize);
-char  *chrom, *name, *strand, *refAllele, *otherAllele, *chimpChrom, *chimpStrand, *chimpAllele, *rhesusChrom, *rhesusStrand, *rhesusAllele;
-chrom = sqlEscapeString(el->chrom);
-name = sqlEscapeString(el->name);
-strand = sqlEscapeString(el->strand);
-refAllele = sqlEscapeString(el->refAllele);
-otherAllele = sqlEscapeString(el->otherAllele);
-chimpChrom = sqlEscapeString(el->chimpChrom);
-chimpStrand = sqlEscapeString(el->chimpStrand);
-chimpAllele = sqlEscapeString(el->chimpAllele);
-rhesusChrom = sqlEscapeString(el->rhesusChrom);
-rhesusStrand = sqlEscapeString(el->rhesusStrand);
-rhesusAllele = sqlEscapeString(el->rhesusAllele);
-
-dyStringPrintf(update, "insert into %s values ( '%s',%u,%u,'%s',%u,'%s','%s','%s','%s',%u,'%s','%s',%u,'%s',%u,'%s','%s',%u)", 
-	tableName,  chrom, el->chromStart , el->chromEnd ,  name, el->score ,  strand,  refAllele,  otherAllele,  chimpChrom, el->chimpPos ,  chimpStrand,  chimpAllele, el->chimpQual ,  rhesusChrom, el->rhesusPos ,  rhesusStrand,  rhesusAllele, el->rhesusQual );
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-freez(&chrom);
-freez(&name);
-freez(&strand);
-freez(&refAllele);
-freez(&otherAllele);
-freez(&chimpChrom);
-freez(&chimpStrand);
-freez(&chimpAllele);
-freez(&rhesusChrom);
-freez(&rhesusStrand);
-freez(&rhesusAllele);
-}
 
 struct hapmapPrimateAlleles *hapmapPrimateAllelesCommaIn(char **pS, struct hapmapPrimateAlleles *ret)
 /* Create a hapmapPrimateAlleles out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new hapmapPrimateAlleles */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->chrom = sqlStringComma(&s);
 ret->chromStart = sqlUnsignedComma(&s);
 ret->chromEnd = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->score = sqlUnsignedComma(&s);