Fix the display of cached text attachment thumbnails.
Review Request #7620 — Created Sept. 9, 2015 and submitted
Text file attachments are marked as safe text, as the thumbnailer will escape/render the text content and wrap it in a div for display. This works fine the first time it's rendered, and works fine with local memory caching. It doesn't work fine when you've rendered it, cached it, and then retrieve it again later. The reason is that the string will start out as safe text, but then it goes into memcached, where it gets stored as a plain string. When it's pulled back out, it's no longer safe. This didn't reproduce in a development environment, since Django's local memory cache stores the object, without converting to a standard string. It only reproduces when using something like memcached. We now mark it as safe once we've fetched from cache. Unit tests were added to check for these conditions.
Unit tests pass. They failed with the expected problem prior to my fix.