-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telegram notifications are not escaped properly #839
Comments
Thx for the report. I have added escape for |
Try page titles with [] brackets.
On Thu, 5 Aug 2021 at 22:15 retif ***@***.***> wrote:
In the version I have (v1.8.1-82f8f6c9-20210504T18:25:06) it's all good:
[image: telegram-escaping]
<https://user-images.githubusercontent.com/6904927/128408025-d9737f0a-494e-415b-9ac2-5d1e0b68ad18.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#839 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPS42K5KKQASKER53ABBC3T3LPNPANCNFSM4VRORYLA>
.
--
Yours sincerely,
Anna Prosvetova
|
Right, sorry, didn't read the original post carefully. Yes, I got the same result: I very vaguely remember having some (similar?) issues with Markdown parsing mode in a couple of my own services, and I think that's why eventually I switched to HTML parsing. However, I've done some tests just now (not with remark42, just plain requests to Telegram API), and escaping in Markdown parsing mode seems to work fine, actually: here's the the cURL command for this request:
If I drop escaping ( here's the cURL for it:
So there seems to be something wrong with the way remark42 forms such links. I don't know how HTTP requests are in Go, but I assume there are fine, and so I would guess the issue is with the URL-encoding of special characters. ...Then I realized that remark42 sends message in request body (doesn't it?), so I tried that, and it's all good there too, here's the cURL:
Sooo, perhaps there is not enough |
If you would like to test it, the function is escapeText. Spoiler: telegram text escaping is complicated, and documentation doesn't match the real behaviour. |
Hmm, the postBody, _ := json.Marshal(map[string]string{
"parse_mode": "MarkdownV2",
"chat_id": config.TelegramChatID,
"disable_web_page_preview": "true",
"text": fmt.Sprintf(
"Here goes [%s](%s) link",
escapeText("some [testing] long"),
"ya.ru",
),
//"text": "Here goes [some \\[testing\\] long](ya.ru) link",
}) and here's the result in Telegram: Which is the expected result. My Go knowledge is not enough to fully understand what's going on in buildTelegramMessage(), but my next guess is that perhaps there is some redundant escaping there for |
@retifrav @aprosvetova please let me know if you'll find any problems in the current |
A bit unrelated to the issue, I don't use Docker, so I wanted to build the latest
Is it an error that it tries to build Docker image (or use Docker for something else?), although README says this command should build a binary? It looks like I'm missing some other steps for building. |
|
Markdown parse_mode is used to make hyperlinks in Telegram notifications:
link = fmt.Sprintf("↦ [%s](%s)", req.Comment.PostTitle, req.Comment.Locator.URL+uiNav+req.Comment.ID)
It breaks if post title contains markdown symbols itself.
Markdown symbols
[ ] ( )
must be escaped with backslash.Post title is
[Contest Ended] Looking for authors: let's create a Flipper story
in this case.The text was updated successfully, but these errors were encountered: