savetheinternet/Tinyboard — pull request #91 by Macil (2013-01-19 01:11:37+00:00)
Title: Post Truncation fixes

These commits fix a few issues with the truncation of long posts in the index pages or mod interface.

[Not all tags require closing tags in HTML5](http://webdesign.about.com/od/htmltags/qt/optional-html-end-tags-when-to-include-them.htm), so if a raw HTML post is made with unclosed
or

tags, the truncated post has them all closed at the end, which can cause issues. Some browsers interpret a
tag as another line break, etc. The first commit fixes this with a list of tags it shouldn't try to close. (That list might not be complete.)

Next, if a raw HTML post contains an HTML comment ( ), then the post could be truncated partway through the comment, causing the rest of the page to be commented out. The second commit fixes this by just removing all HTML comments from the post before truncating it. The comments are still there when the thread is directly viewed. (Alternatively, it could be fixed like broken HTML entities are, leaving in any comments, but I didn't figure it was worth it. And I figured that characters in comments shouldn't count toward the max_chars limit.)

The third commit makes it so post truncation is done by the actual character count rather than byte count. Besides being more accurate and preventing cutting apart multi-byte character sequences, this fixes a bug where if a long post with many multi-byte characters is reported, the Dismiss buttons (and more) may be cut off from the report.