Adding comment with emoji hex strings copied from console when creating new issue causes internal server error 500 #9054

Closed
opened 2025-11-02 08:27:20 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @flipkickmedia on GitHub (Jun 12, 2022).

Description

  • create a new issue
  • paste some content with ANSI inside it.
  • get the error

This bug is caused by pasting emojis into the issue.

Github is stripping the ANSI when I try to provide an example of some content to reproduce but does include the emoji.

To reproduce, paste this into a new issue:

menu      menu_item       12/06/2022 15:34:05+01 [ -- ]  --test-switch1                  [✅ ]                               no description        

The code which generates the emojis (bash shell):

  if [[ $value == "" ]]; then
    declare -n fg_colour_value="FK_LOG_NOTICE_FG"
    value="[\xF0\x9F\x94\xB2 ]"
  elif [[ $value == true ]]; then
    declare -n fg_colour_value="FK_LOG_OK_FG"
    value="[\xE2\x9C\x85 ]"
  elif [[ $value != true && $value != false ]]; then
    declare -n fg_colour_value="FK_LOG_OK_FG"
    value="[ ${value} ]"
  elif [[ $value == false ]]; then
    declare -n fg_colour_value="FK_LOG_OK_FG"
    value="[ ${value} ]"
  fi

You get this error:

Error 1366: Incorrect string value: '\xF0\x9F\x94\xB2 ]...' for column `gitea`.`comment`.`content` at row 1

Gitea Version

1.16.8

Can you reproduce the bug on the Gitea demo site?

No - Can't reproduce on the gitea test instance as I don't receive the signup email.

Log Gist

Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= show-ref --tags
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch-check
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= show-ref --heads
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...rs/web/repo/issue.go:2181:NewComment() [E] CreateIssueComment: Error 1366: Incorrect string value: '\xF0\x9F\x94\xB2 ]...' for column `gitea`.`comment`.`content` at row 1
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...s/context/context.go:214:HTML() [D] Template: status/500
Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 Completed POST /cme/cme-cme/issues/2/comments 500 Internal Server Error in 202.133516ms

Screenshots

image

image

Git Version

1.16.8

Operating System

Linux Ubuntu 22.10

How are you running Gitea?

service

Database

MySQL

Originally created by @flipkickmedia on GitHub (Jun 12, 2022). ### Description - create a new issue - paste some content with ANSI inside it. - get the error This bug is caused by pasting emojis into the issue. Github is stripping the ANSI when I try to provide an example of some content to reproduce but does include the emoji. To reproduce, paste this into a new issue: ``` menu menu_item 12/06/2022 15:34:05+01 [ -- ] --test-switch1 [✅ ] no description ``` The code which generates the emojis (bash shell): ```shell if [[ $value == "" ]]; then declare -n fg_colour_value="FK_LOG_NOTICE_FG" value="[\xF0\x9F\x94\xB2 ]" elif [[ $value == true ]]; then declare -n fg_colour_value="FK_LOG_OK_FG" value="[\xE2\x9C\x85 ]" elif [[ $value != true && $value != false ]]; then declare -n fg_colour_value="FK_LOG_OK_FG" value="[ ${value} ]" elif [[ $value == false ]]; then declare -n fg_colour_value="FK_LOG_OK_FG" value="[ ${value} ]" fi ``` You get this error: ``` Error 1366: Incorrect string value: '\xF0\x9F\x94\xB2 ]...' for column `gitea`.`comment`.`content` at row 1 ``` ### Gitea Version 1.16.8 ### Can you reproduce the bug on the Gitea demo site? No - Can't reproduce on the gitea test instance as I don't receive the signup email. ### Log Gist ``` Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= show-ref --tags Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch-check Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...dules/git/command.go:146:RunWithContext() [D] /home/git/cme/cme-cme.git: /usr/bin/git -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= show-ref --heads Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...rs/web/repo/issue.go:2181:NewComment() [E] CreateIssueComment: Error 1366: Incorrect string value: '\xF0\x9F\x94\xB2 ]...' for column `gitea`.`comment`.`content` at row 1 Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 ...s/context/context.go:214:HTML() [D] Template: status/500 Jun 12 15:16:20 ninja.flipkick.media gitea[3333799]: 2022/06/12 15:16:20 Completed POST /cme/cme-cme/issues/2/comments 500 Internal Server Error in 202.133516ms ``` ### Screenshots ![image](https://user-images.githubusercontent.com/15732784/173240245-21f73323-8a59-4438-81a2-7857a121708b.png) ![image](https://user-images.githubusercontent.com/15732784/173239522-dae14794-0421-4fc8-8256-89ad02454d62.png) ### Git Version 1.16.8 ### Operating System Linux Ubuntu 22.10 ### How are you running Gitea? service ### Database MySQL
GiteaMirror added the type/bugissue/needs-feedback labels 2025-11-02 08:27:20 -06:00
Author
Owner

@lunny commented on GitHub (Jun 13, 2022):

Please ensure you are using utf8mb4 charactor with MySQL.

@lunny commented on GitHub (Jun 13, 2022): Please ensure you are using utf8mb4 charactor with MySQL.
Author
Owner

@flipkickmedia commented on GitHub (Jun 14, 2022):

Gitea is solely responsible for setting up the/seeding and migrating the database and encoding copied data from the console pasted into an issue.

github can handle it, as can gitlab etc.

As this is a copy and paste a user shouldn't be expected to encode the clipboard data into a format gitea can store.

Is this something in the gitea config I can change to make this work?

I'm using MariaDB.

@flipkickmedia commented on GitHub (Jun 14, 2022): Gitea is solely responsible for setting up the/seeding and migrating the database and encoding copied data from the console pasted into an issue. github can handle it, as can gitlab etc. As this is a copy and paste a user shouldn't be expected to encode the clipboard data into a format gitea can store. Is this something in the gitea config I can change to make this work? I'm using MariaDB.
Author
Owner

@lunny commented on GitHub (Jun 17, 2022):

You need change both sides. From MariaDB, create the database with utf8mb4 and set that as default. From Gitea, confirm that CHARSET in app.ini is utf8mb4. If you have already set up the instance, an extra step is to convert the database and table from utf8 to utf8mb4.

@lunny commented on GitHub (Jun 17, 2022): You need change both sides. From MariaDB, create the database with utf8mb4 and set that as default. From Gitea, confirm that CHARSET in app.ini is `utf8mb4`. If you have already set up the instance, an extra step is to convert the database and table from `utf8` to `utf8mb4`.
Author
Owner

@wxiaoguang commented on GitHub (Jun 23, 2022):

Follow this guide to convert utf8 to utf8mb4

https://dba.stackexchange.com/questions/8239/how-to-easily-convert-utf8-tables-to-utf8mb4-in-mysql-5-5

@wxiaoguang commented on GitHub (Jun 23, 2022): Follow this guide to convert utf8 to utf8mb4 https://dba.stackexchange.com/questions/8239/how-to-easily-convert-utf8-tables-to-utf8mb4-in-mysql-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9054