go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.33k stars 5.33k forks source link

Telegram webhook error when commit message contains special characters #31182

Closed babykart closed 1 week ago

babykart commented 1 month ago

Description

Telegram webhook respond an error code 400 when commit message contains special characters. Example message:

{
  "text": "[\u003ca href=\"https://git.example.com/babykart/et0ie\"\u003eKubler/et0ie\u003c/a\u003e:\u003ca href=\"https://git.example.com/babykart/et0ie/commit/6e873e503dd22aa4bf5e577bc9aa348e7b842cf7\"\u003emain\u003c/a\u003e] 1 new commit\n[\u003ca href=\"https://git.example.com/babykart/et0ie/commit/6e873e503dd22aa4bf5e577bc9aa348e7b842cf7\"\u003e6e873e5\u003c/a\u003e] [et0ie] caddy-24.05.301\n\nSigned-off-by: babykart \u003cbabykart@gmail.com\u003e - babykart",
  "parse_mode": "HTML",
  "disable_web_page_preview": true
}

Response:

{"ok":false,"error_code":400,"description":"Bad Request: can't parse entities: Unsupported start tag \"babykart@gmail.com\" at byte offset 326"}

These messages perfectly work with the version 1.21.11.

Gitea Version

1.22.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.45.1

Operating System

Gentoo Linux

How are you running Gitea?

Downloaded from https://github.com/go-gitea/gitea/releases/download/v1.22.0/gitea-1.22.0-linux-amd64

Database

PostgreSQL

POPSuL commented 1 week ago

https://github.com/go-gitea/gitea/pull/29864 That fix broke it.

wxiaoguang commented 1 week ago

-> Use old behavior for telegram webhook #31588


Update: the old code for telegram webhook had some problems, so in 1.23 it needs more fixes.

wxiaoguang commented 1 week ago

" Use old behavior for telegram webhook #31588 " has been merged, when the next 1.22-nightly build is ready, please take a try.