48272e481ae9768378a88da5019d61706e9feb9c angie Fri Mar 10 11:12:53 2017 -0800 Libify the hgTables fix for problematic characters in download filenames and apply to hgVai, hgIntegrator and hgSession. Thanks Jairo! refs #18931 note-10 diff --git src/lib/textOut.c src/lib/textOut.c index 9ab111e..f261ebb 100644 --- src/lib/textOut.c +++ src/lib/textOut.c @@ -182,15 +182,26 @@ pipelineClose(pCompressPipeline); } if (saveStdout) { if (*saveStdout != -1) { /* restore stdout */ fflush(stdout); dup2(*saveStdout,STDOUT_FILENO); /* closes STDOUT before setting it back to saved descriptor */ close(*saveStdout); *saveStdout = -1; } } } +char *textOutSanitizeHttpFileName(char *fileName) +/* Replace troublesome characters in a fileName for HTTP download entered by the user, + * such as '/' which textOutInit interprets as implying a local file and ',' which + * messes up the HTTP response header syntax. */ +{ +char *sanitized = cloneString(skipLeadingSpaces(fileName)); +eraseTrailingSpaces(sanitized); +subChar(sanitized, '/', '_'); +subChar(sanitized, ',', '.'); +return sanitized; +}