savetheinternet/Tinyboard — pull request #102 by ctrlcctrlv (2013-03-17 11:11:09+00:00)
Title: Fix truncation issues once and for all 

I've been working on this commit for a while, and my original work all had to do with keeping HTML entities intact.

I scrapped all of that in favor of this simple change. This permanently fixes the truncation issues that plague tinyboard, but is still secure (i.e., it still encodes <, >, &, etc).

The truncation issue is very simple, currently, when Tinyboard receives a Unicode filename, like `スクリーンショット.png`, it converts it into HTML entities...

`スクリーンショット.png`

And then _erroneously_ uses these to truncate at the set number, which not only slices in the wrong place, but cuts HTML entities in half, resulting in `スクリӦ` or `スクリӦ…`.

This affects all fields with truncation, including the body text, which can also be truncated in the middle of an HTML entity.

I tried to fix this a few different ways but eventually just decided it's 2013 and server admins should set their `Content-Type` to `utf-8` already. I hope you will accept this pull request.

![2013-03-17-070939_906x359_scrot](https://f.cloud.github.com/assets/838783/267987/37892a18-8ef3-11e2-9c94-65c20115eaa7.png)
This image shows the fix with this patch.