7a356d85dba1647c6d918b315e075da7e31ab7cb braney Sat Sep 26 12:10:36 2026 -0700 htmlSanitize: keep simple svg drawings in hub description pages, refs #38428 Description pages that draw small svg shapes, such as a colour legend, came out empty. svg, g, circle, ellipse, rect, line, polyline, polygon and path now come through with their size, position, fill and stroke attributes. Other svg elements are left out. Over the 5390-page hub corpus only the 32 pages that contain an svg change, and no page's text changes. diff --git src/lib/tests/htmlSanitizeTest.c src/lib/tests/htmlSanitizeTest.c index cd081f855cd..6d4595e3670 100644 --- src/lib/tests/htmlSanitizeTest.c +++ src/lib/tests/htmlSanitizeTest.c @@ -1,100 +1,121 @@ /* htmlSanitizeTest - check that htmlSanitize keeps what it should and drops the rest. */ /* Copyright (C) 2026 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #include "common.h" #include "htmlSanitize.h" static char *cases[] = { /* a whole pasted document comes out as the article it was meant to be */ "T" "

Head

Text

", /* script and style go, with their contents */ "

before

after

", /* a script that is never closed takes the rest with it */ "

before

" + "" + "" + "" + "

text

", +/* a fill or a stroke cannot fetch anything, however the url is spelled */ +"" + "", +/* a shape that only clips another is not drawn on its own */ +"" + "", +/* a shape outside a drawing loses its tag */ +"text after", }; int main(int argc, char *argv[]) { int i; for (i = 0; i < ArraySize(cases); ++i) { char *clean = htmlSanitize(cases[i]); printf("in : %s\nout: %s\n", cases[i], clean); struct slName *removed = NULL, *el; freeMem(clean); clean = htmlSanitizeReport(cases[i], &removed); for (el = removed; el != NULL; el = el->next) printf(" (%s)\n", el->name); printf("\n"); freeMem(clean); slFreeList(&removed); } /* Running the filter over its own output has to leave it alone. hgCustom hands the text * we returned back to us when a custom track is edited and saved again, so anything that * changes on a second pass changes a little more on every save. Any case that is not * settled prints here, and the expected output is the record of which ones those are. */ for (i = 0; i < ArraySize(cases); ++i) { char *once = htmlSanitize(cases[i]); char *twice = htmlSanitize(once); if (differentString(once, twice)) printf("not settled:\n once : %s\n twice: %s\n\n", once, twice); freeMem(once); freeMem(twice); } if (htmlSanitize(NULL) != NULL) errAbort("htmlSanitize(NULL) should be NULL"); return 0; }