Fix truncation issues once and for all #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
スクリーンショット<b>.png
, it converts it into HTML entities...スクリーンショット<b>.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
toutf-8
already. I hope you will accept this pull request.This image shows the fix with this patch.