Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 Actions Header #737

Closed
cfouche3005 opened this issue May 20, 2023 · 3 comments
Closed

UTF-8 Actions Header #737

cfouche3005 opened this issue May 20, 2023 · 3 comments
Labels
馃 bug Something isn't working

Comments

@cfouche3005
Copy link

cfouche3005 commented May 20, 2023

馃悶 Describe the bug

Ntfy server seem to block every POST request with an UTF-8 character ( 脿 ) inside the Actions Header (for the label) but when I had an an UTF-8 character inside the Title Header or the body, it is processed normally and give the correct output or an unknow character due to bad UTF-8 processing (not a bug, I think)

馃捇 Components impacted

Ntfy Server

馃挕 Screenshots and/or logs

ntfy server log:

2023/05/20 18:02:55 DEBUG Connection closed with HTTP 400 (ntfy error 40018) (error=invalid request: actions invalid; invalid utf-8 string, error_code=40018, http_method=POST, http_path=/Netbird, http_status=400, tag=http, topic=Netbird, topic_last_access=2023-05-20T18:02:44.21Z, topic_subscribers=1, user_id=u_Iyy0BJTPUR, user_name=cfouche, visitor_auth_limiter_limit=0.016666666666666666, visitor_auth_limiter_tokens=30, visitor_emails=0, visitor_emails_limit=24, visitor_emails_remaining=24, visitor_id=ip:REDACTED, visitor_ip=REDACTED, visitor_messages=0, visitor_messages_limit=17280, visitor_messages_remaining=17280, visitor_request_limiter_limit=0.2, visitor_request_limiter_tokens=59.000016648, visitor_seen=2023-05-20T18:02:55.92Z)

image

Actions Header : http, "Mettre 脿 jour", "https://REDACTED/webhook/netbird-update", method=GET, headers.AUTH=REDACTED

馃敭 Additional context

I can't use the JSON method because I need the Icon parameter and it isn't supported

@cfouche3005 cfouche3005 added the 馃 bug Something isn't working label May 20, 2023
@binwiederhier
Copy link
Owner

UTF-8 headers are supported by the ntfy server, but many clients have trouble with it. So it is likely that your IDE and/or programming language is incorrectly encoding the header. This is because the HTTP spec doesn't officially support UTF-8 header.

It works on Linux with curl:

$ curl -d "hi there" -H 'Actions: http, "Mettre 脿 jour", "https://REDACTED/webhook/netbird-update", method=GET, headers.AUTH=REDACTED' ntfy.sh/test12
{"id":"3CSBNE1cyHEh","time":1684704669,"expires":1684747869,"event":"message","topic":"test12","message":"hi there","actions":[{"id":"4jvCVVB6D4","action":"http","label":"Mettre 脿 jour","clear":false,"url":"https://REDACTED/webhook/netbird-update","method":"GET","headers":{"AUTH":"REDACTED"}}]}

That said, a few of the other headers can already be encoded with RFC 2047 type strings, but the action description cannot. Maybe we should add that support too. Then you could do:

http, "=?utf-8?q?Mettre =C3=A0 jour?=", "https://REDACTED/webhook/netbird-update"

I think that's reasonable.

I can't use the JSON method because I need the Icon parameter and it isn't supported

The icon param should be supported. Here's and example with curl:

$ curl -d '{"topic":"test123","icon":"http://some.icon.org/hi.jpg"}' ntfy.sh
{"id":"WCDj1GfaF6H4","time":1684705371,"expires":1684748571,"event":"message","topic":"test123","message":"triggered","icon":"http://some.icon.org/hi.jpg"}

@cfouche3005
Copy link
Author

cfouche3005 commented May 21, 2023

That said, a few of the other headers can already be encoded with RFC 2047 type strings, but the action description cannot. Maybe we should add that support too.

Yes, It would be very nice.

The icon param should be supported.

It was not inside the overview of the supported field of the documentation so I thought it was not supported
https://docs.ntfy.sh/publish/#publish-as-json

@binwiederhier
Copy link
Owner

Done in 168ad8b -- Will be in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants