0b8725960bf37ad6f82163177238c75ff2a2f3b5
larrym
  Wed Nov 16 14:19:20 2011 -0800
use attributeEncode instead of htmlEncode in title attributes (e.g. allow encoded unicode)
diff --git src/hg/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c
index 5c8095c..348343a 100644
--- src/hg/hgTracks/imageV2.c
+++ src/hg/hgTracks/imageV2.c
@@ -1634,61 +1634,61 @@
         }
     else if(item->linkVar != NULL)
         {
         if(skipToSpaces(item->linkVar))
             hPrintf(" HREF=%s",item->linkVar);
         else if(startsWith("/cgi-bin/hgGene", item->linkVar)) // redmine #4151
                  hPrintf(" HREF='..%s'",item->linkVar);       // FIXME: Chin should get rid of this special case!
              else
                  hPrintf(" HREF='%s'",item->linkVar);
         hPrintf(" class='area'");
         }
     else
         warn("map item has no url!");
 
     if(item->title != NULL && strlen(item->title) > 0)
-        hPrintf(" TITLE='%s'", htmlEncode(item->title) );
+        hPrintf(" TITLE='%s'", attributeEncode(item->title) );
     if(item->id != NULL)
         hPrintf(" id='%s'", item->id);
     hPrintf(">" );
     }
 hPrintf("</MAP>\n");
 return TRUE;
 }
 
 static void imageDraw(struct imgBox *imgBox,struct imgTrack *imgTrack,struct imgSlice *slice,char *name,int offsetX,int offsetY,boolean useMap)
 /* writes an image as HTML */
 {
 if(slice->parentImg && slice->parentImg->file != NULL)
     {
     hPrintf("  <IMG id='img_%s' src='%s' style='left:-%dpx; top: -%dpx;'",
             name,slice->parentImg->file,offsetX,offsetY);
     // Problem: dragScroll beyond left shows ugly leftLabel!
     // Tried clip:rect() but this only works with position:absolute!
     // May need to split image betweeen side label and data!!! That is a big change.
 
     if(useMap)
         hPrintf(" usemap='#map_%s'",name);
     hPrintf(" class='sliceImg %s",sliceTypeToClass(slice->type));
     if(slice->type==stData && imgBox->showPortal)
         hPrintf(" panImg'");
     else
         hPrintf("'");
     if(slice->title != NULL)
-        hPrintf(" title='%s'", htmlEncode(slice->title) );           // Adds slice wide title
+        hPrintf(" title='%s'", attributeEncode(slice->title) );           // Adds slice wide title
     else if(slice->parentImg->title != NULL)
-        hPrintf("' title='%s'", htmlEncode(slice->parentImg->title) );// Adds image wide title
+        hPrintf("' title='%s'", attributeEncode(slice->parentImg->title) );// Adds image wide title
     if(slice->type==stData || slice->type==stCenter)
         hPrintf(" ondrag='{return false;}'");
     hPrintf(">");
     }
 else
     {
     int height = slice->height;
     // Adjustment for centerLabel Conditional
     if (imgTrack->centerLabelSeen == clNotSeen
     &&  (slice->type == stSide || slice->type == stButton))
         {
         struct imgSlice *centerSlice = imgTrackSliceGetByType(imgTrack,stCenter);
         if (centerSlice != NULL)
             height -= centerSlice->height;
         }
@@ -1770,37 +1770,37 @@
         { // This fake link ensures a mouse-over title is seen but not heard
         hPrintf("<A class='%s'",TITLE_BUT_NO_LINK);
         }
     else if(skipToSpaces(slice->link) != NULL)
         hPrintf("  <A HREF=%s",slice->link);
     else
         hPrintf("  <A HREF='%s'",slice->link);
     if (slice->title != NULL)
         {
         if (sliceType == stButton)
             {
             enum browserType browser = cgiClientBrowser(NULL,NULL,NULL);
             char *newLine = NEWLINE_TO_USE(browser);
             char *ellipsis = ELLIPSIS_TO_USE(browser);
             if(imgTrack->reorderable)
-                hPrintf(" TITLE='%s%sclick or right click to configure%s%sdrag to reorder%s'",htmlEncode(slice->title), newLine,
+                hPrintf(" TITLE='%s%sclick or right click to configure%s%sdrag to reorder%s'",attributeEncode(slice->title), newLine,
                     ellipsis, newLine,(tdbIsCompositeChild(imgTrack->tdb)?" highlighted subtracks":"") );
             else
-                hPrintf(" TITLE='%s%sclick or right click to configure%s'",htmlEncode(slice->title), newLine, ellipsis);
+                hPrintf(" TITLE='%s%sclick or right click to configure%s'",attributeEncode(slice->title), newLine, ellipsis);
             }
         else
-            hPrintf(" TITLE='Click for: &#x0A;%s'", htmlEncode(slice->title) );
+            hPrintf(" TITLE='Click for: &#x0A;%s'", attributeEncode(slice->title) );
         }
     hPrintf(">\n" );
     }
 
 imageDraw(imgBox,imgTrack,slice,name,offsetX,offsetY,useMap);
 if(slice->link != NULL)
     hPrintf("</A>");
 
 if(slice->parentImg)
     hPrintf("</div>");
 }
 
 void imageBoxDraw(struct imgBox *imgBox)
 /* writes a entire imgBox including all tracksas HTML */
 {
@@ -1874,61 +1874,61 @@
     hPrintf("<TR id='tr_%s' abbr='%d' class='imgOrd%s%s%s'>\n",trackName,imgTrack->order,
         (imgTrack->reorderable?" trDraggable":" nodrop nodrag"),
         (imgTrack->centerLabelSeen != clAlways?" clOpt":""),
         (imgTrack->ajaxRetrieval ?" mustRetrieve":""));
 
     if(imgBox->showSideLabel && imgBox->plusStrand)
         {
         // button
         safef(name, sizeof(name), "btn_%s", trackName);
         hPrintf(" <TD id='td_%s'%s>\n",name,(imgTrack->reorderable?" class='dragHandle'":""));
         sliceAndMapDraw(imgBox,imgTrack,stButton,name,FALSE);
         hPrintf("</TD>\n");
         // leftLabel
         safef(name,sizeof(name),"side_%s",trackName);
         if (imgTrack->reorderable)
-            hPrintf(" <TD id='td_%s' class='dragHandle tdLeft' title='%s%sdrag to reorder'>\n",name,htmlEncode(imgTrack->tdb->longLabel),newLine);
+            hPrintf(" <TD id='td_%s' class='dragHandle tdLeft' title='%s%sdrag to reorder'>\n",name,attributeEncode(imgTrack->tdb->longLabel),newLine);
         else
             hPrintf(" <TD id='td_%s' class='tdLeft'>\n",name);
         sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE);
         hPrintf("</TD>\n");
         }
 
     // Main/Data image region
 #ifdef IMAGEv2_DRAG_SCROLL
     hPrintf(" <TD id='td_data_%s' title='click & drag to scroll; shift+click & drag to zoom' width=%d class='tdData'>\n", trackName, imgBox->width);
 #else///ifndef IMAGEv2_DRAG_SCROLL
     hPrintf(" <TD id='td_data_%s' width=%d class='tdData'>\n", trackName, imgBox->width);
 #endif//ndef IMAGEv2_DRAG_SCROLL
     // centerLabel
     if(imgTrack->hasCenterLabel)
         {
         safef(name, sizeof(name), "center_%s", trackName);
         sliceAndMapDraw(imgBox,imgTrack,stCenter,name,TRUE);
         hPrintf("\n");
         }
     // data image
     safef(name, sizeof(name), "data_%s", trackName);
     sliceAndMapDraw(imgBox,imgTrack,stData,name,(imgTrack->order>0));
     hPrintf("</TD>\n");
 
     if(imgBox->showSideLabel && !imgTrack->plusStrand)
         {
         // rightLabel
         safef(name, sizeof(name), "side_%s", trackName);
         if (imgTrack->reorderable)
-            hPrintf(" <TD id='td_%s' class='dragHandle tdRight' title='%s%sdrag to reorder'>\n",name,htmlEncode(imgTrack->tdb->longLabel),newLine);
+            hPrintf(" <TD id='td_%s' class='dragHandle tdRight' title='%s%sdrag to reorder'>\n",name,attributeEncode(imgTrack->tdb->longLabel),newLine);
         else
             hPrintf(" <TD id='td_%s' class='tdRight'>\n",name);
         sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE);
         hPrintf("</TD>\n");
         // button
         safef(name, sizeof(name), "btn_%s", trackName);
         hPrintf(" <TD id='td_%s'%s>\n",name,(imgTrack->reorderable?" class='dragHandle'":""));
         sliceAndMapDraw(imgBox,imgTrack,stButton, name,FALSE);
         hPrintf("</TD>\n");
         }
     hPrintf("</TR>\n");
     }
 hPrintf("</TABLE>\n");
 hPrintf("<!-- - - - - - - - ^^^ IMAGEv2 ^^^ - - - - - - - -->\n");  // DANGER FF interprets '--' as end of comment, not '-->'
 jsonTdbSettingsUse(jsonTdbVars);