savetheinternet/Tinyboard — pull request #114 by Macil (2013-06-18 16:31:25+00:00)
Title: Fix display issues with RTL control characters in post names, subjects, ...

Fix display issues with RTL control characters in post names, subjects, and filenames.

A user who uses Right-to-Left Embedding or Override characters in their name, subject, or filenames can mess up the visual appearance of other fields on the same line. (This isn't an issue for the post body for example, because nothing else is displayed on the same line as it.)

This commit fixes it by introducing the bidi_cleanup function (called from within the templates), which pairs all LRE, RLE, LRO, RLO characters with Pop-Directional-Formatting characters (and removes any improper PDF characters), based on code from http://www.iamcal.com/understanding-bidirectional-text/