Skip to content

Allow emoji in attention titles and descriptions - #439

Open
ECYaz wants to merge 1 commit into
phpbb:3.3.xfrom
ECYaz:fix/371-emoji-attention
Open

Allow emoji in attention titles and descriptions#439
ECYaz wants to merge 1 commit into
phpbb:3.3.xfrom
ECYaz:fix/371-emoji-attention

Conversation

@ECYaz

@ECYaz ECYaz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #371.

Reporting a post or a contribution writes the subject and the reason straight into attention_title and attention_description. Unlike the message fields these never pass through the text formatter, so a four byte character such as an emoji reaches the utf8 columns as-is and MySQL rejects the row:

Incorrect string value: '\xF0\x9F\x86\x95 t...' for column 'attention_title' at row 1 [1366]

This uses utf8_encode_ucr() on the way in, the same thing core does to report text in phpbb\report\controller\report, per @iMattPro's suggestion on #390. Doing it in titania_attention::submit() covers all three places that create attention rows rather than patching each one.

Nothing needs decoding on the way out, since a character reference renders as the character it stands for.

Checked on a local board:

  • reporting with an emoji in the subject and in the reason now succeeds
  • four byte characters outside the emoji range are handled too, a rare CJK ideograph encodes the same way
  • accented characters are left alone, only four byte sequences are touched
  • plain text is unchanged, and rows written before this change read back exactly as before
  • the encoding is stable, so a caller passing text that already carries a character reference does not end up with it encoded twice
  • closing a report does not re-encode it

The columns could instead be moved to utf8mb4, but the driver connects with SET NAMES 'utf8', so the insert still fails at the connection before the column charset applies. That is PHPBB-16137, still awaiting review.

Reporting a post or a contribution writes the subject and the reason straight
into attention_title and attention_description. Unlike the message fields
these never pass through the text formatter, so a four byte character such as
an emoji reaches the utf8 columns as-is and MySQL rejects the row:

  Incorrect string value: '\xF0\x9F\x86\x95 t...' for column
  'attention_title' at row 1 [1366]

Replace those characters with their numeric character reference on the way in,
using the same utf8_encode_ucr() core applies to report text. Doing it in
submit() covers all three places that create attention rows.

Nothing needs decoding on the way out, since a character reference renders as
the character it stands for. Rows written before this change are unaffected,
and the encoding is stable if it is applied to text that already carries one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL error: Incorrect string value: '\xF0\x9F\x98\x84 \xF0...' for column 'attention_description' at row 1

1 participant