summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-07-31 12:05:19 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-07-31 12:05:19 -0400
commit8e4c493a4c5bbff07483fd4a11c44c687c99e441 (patch)
treef85541ea3ac9e22174e4a776aec9da90023fea94 /post.php
parent659310663e9e7c2163234fbbc9ce922147328aa1 (diff)
Issue #126
Diffstat (limited to 'post.php')
-rw-r--r--post.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/post.php b/post.php
index 85dc2d05..a82b56ad 100644
--- a/post.php
+++ b/post.php
@@ -378,10 +378,22 @@ if (isset($_POST['delete'])) {
wordfilters($post['body']);
- if (mysql_version() >= 50503)
+ if (mysql_version() >= 50503) {
$post['body_nomarkup'] = $post['body']; // Assume we're using the utf8mb4 charset
- else
- $post['body_nomarkup'] = preg_replace('/[\x{010000}-\x{ffffff}]/u', '', $post['body']); // MySQL's `utf8` charset only supports up to 3-byte symbols
+ } else {
+ // MySQL's `utf8` charset only supports up to 3-byte symbols
+ // Remove anything >= 0x010000
+
+ $chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
+ $post['body_nomarkup'] = '';
+ foreach ($chars as $char) {
+ $o = 0;
+ $ord = ordutf8($char, $o);
+ if ($ord >= 0x010000)
+ continue;
+ $post['body_nomarkup'] .= $char;
+ }
+ }
if (!($mod && isset($post['raw']) && $post['raw']))
$post['tracked_cites'] = markup($post['body'], true);