-
Notifications
You must be signed in to change notification settings - Fork 74
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
Encoding problem for ajax return in the "apache" variant of 10.1 #1470
Comments
First surprise, the Umlaute look as expected to me. Tested with running Firefox 94.0 and Chromium Version 96.0.4664.45 under Linux. So this effect might be browser dependent. But let's see what possible could go wrong. The page http://localhost/otobo/index.pl?Action=AgentStatistics;Subaction=Add looks initially fine. The content-type is not surprisingly ext/html; charset=utf-8. Clicking on Dynamische Matrix loads the HTML snippet http://localhost/otobo/index.pl?Action=AgentStatistics;Subaction=GeneralSpecificationsWidgetAJAX via the JavaScript code:
The snippet has content type text/html, but the content is UTF-8 encoded, subsequently the output is messed up. Lets doublecheck. Pasting "können" into vim and use 'g8' on the funny chars gives us the hex encodings "c373" and "c2b6" for the funny chars. Looking up the code points we confirm that the funny chars are the bytes of UTF-8 encoded 'ö' encoded as UTF-8.
The guess is that we need to declare the content of the snippet as UTF-8. |
Declaration as UTF-8 can done with the parameter Charset UTF-8 in the method
Let's try whether adding the Charset parameter fixes the problem. |
Testing this in the virtual OTOBO installation where the error was noticed. Opening the snippet, without the fix from 32119fa, shows a sane 'ö'. Doublechecking the page info, "Extras" -> "Seiteninformationen" confirms that the virtual OTOBO delivers the page content as ISO-8859-1, or windows-1252. This means that for some reason there is defined difference between the behaviour in the local installation and in the virtual OTOBO. But in a way that divergent behaviour is fine. Perl make no promises regarding the internal representation of strings. Therefore Perl is allowed to downgrade the HTML snippet if it possible. It is the responsibility of the OTOBO developer to make sure that the delivered bytes and the Content-Type declaration are in sync. This guarantee is achieved by passing Doublechecking this by manually adapting Kernel::Modules::AgentStatistics.pm gave the expected result. The snippet still looks fine, while the page info reports UTF-8 as charset. Inserting the UTF-8 content in the UTF-8 encoded containing page now works fine too. |
PR is merged. Created a new virtual OTOBO for the rel-10_1 branch. The page otobo/index.pl?Action=AgentStatistics;Subaction=Add looks fine. Closing this issue. |
There are probably 200 instances where Attachment() is called and likely returned somewhere. Do you know at which place the encoding was "fixed" in 10.0? Because either we have to check all places individually, or we should try to change this in a common spot... I will reopen this for the moment, if I misunderstood something, please just close it again. |
TODO:
|
Even though it would make the code more readable
Because it is not obvious that the content should be UTF-8 encoded.
Checked the calls to |
TODO: check whether one of these test failures is related to the changes:
|
There has been an issue with an missing or misspelled Charset declaration for JSON responses. Checking RFC8259, https://datatracker.ietf.org/doc/html/rfc8259, I see that the charset declaration is optional:
Therefore Kernel::System::Web::Response::Finalize() should encode all JSON responses, that is responses with Content-Type: application/json. |
Issue #1470: turn off UTF8-flag in a hard way wenn in doubt
No further problems were encountered. Closing this issue. |
To see the effect visit /otobo/index.pl?Action=AgentStatistics;Subaction=Add and with a German profile click e.g. on "Dynamische Matrix".
This is currently fetched in line 63 of var/httpd/htdocs/js/Core.Agent.Statistics.js, the probably important side is Kernel/Modules/AgentStatistics.pm Subaction=GeneralSpecificationsWidgetAJAX
The text was updated successfully, but these errors were encountered: