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/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c
index 3c2a372..4342e7d 100644
--- src/hg/hgTracks/imageV2.c
+++ src/hg/hgTracks/imageV2.c
@@ -1800,31 +1800,35 @@
     // 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) //  || slice->type==stCenter will make centerLabels scroll too
         hPrintf(" panImg'");
     else
         hPrintf("'");
     if (slice->title != NULL)
         hPrintf(" title='%s'", attributeEncode(slice->title) );           // Adds slice wide title
     else if (slice->parentImg->title != NULL)
         hPrintf("' title='%s'", attributeEncode(slice->parentImg->title) );// Adds image wide title
     if (slice->type==stData || slice->type==stCenter)
-        hPrintf(" ondrag='{return false;}'");
+	{
+	char id[256];
+	safef(id, sizeof id, "img_%s", name);
+	jsOnEventById("drag", id, "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;
         }
 
     hPrintf("  <p id='p_%s' style='height:%dpx;",name,height);