Fix non-ascii characters present in the header#30614
Fix non-ascii characters present in the header#30614PVince81 merged 1 commit intonextcloud:masterfrom Marek-Wojtowicz:patch-1
Conversation
|
@Marek-Wojtowicz can you fix the DCO please? |
The http headers according to rfc 2616 is iso-8859-1. This patch fixes the behavior when non-ascii characters are present in the header. Signed-off-by: Marek Wójtowicz <Marek.Wojtowicz@agh.edu.pl>
|
I think I fixed the DCO 😄 |
CarlSchwan
left a comment
There was a problem hiding this comment.
This looks sensible but I'm not familiar enough with how the session token works inside nextcloud to say if this might or not break anything
|
An SQL query is fired, inserting a token into the oc_authtoken table. Specifically, the userAgent column has a wrong character encoding (MySQL returns: Incorrect string value). |
|
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
|
Backports? |
| return false; | ||
| } | ||
| $name = isset($request->server['HTTP_USER_AGENT']) ? $request->server['HTTP_USER_AGENT'] : 'unknown browser'; | ||
| $name = isset($request->server['HTTP_USER_AGENT']) ? utf8_encode($request->server['HTTP_USER_AGENT']) : 'unknown browser'; |
There was a problem hiding this comment.
utf8_encode is a wrongly named php function, I’d feel better if either we have our own alias named iso-8859-1_to_utf8(), or if we use mb_convert_encoding instead (only possible if we depend upon mbstring).
There are frequent proposal to remove utf8_encode from PHP, all were rejected so far, but it shows this function is confusing.
There was a problem hiding this comment.
I think there will be time to fix the problem as utf8_encode becomes obsolete. Until then, there may be newer mechanisms that can replace utf8_encode.
|
/backport to stable23 |
|
/backport to stable22 |
|
/backport to stable21 |
The http headers according to rfc 2616 is iso-8859-1. This patch fixes the behavior when non-ascii characters are present in the header.