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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding issues with CGI scripts wrapping otobo.psgi #1106

Closed
bschmalhofer opened this issue Jul 1, 2021 · 6 comments
Closed

Encoding issues with CGI scripts wrapping otobo.psgi #1106

bschmalhofer opened this issue Jul 1, 2021 · 6 comments
Milestone

Comments

@bschmalhofer
Copy link
Contributor

Another class of failures from the cgi-bin wrapper scripts:

not ok 14 - Breadcrumb text 'Add Auto Response' is found on screen (is 'Automatische Antwort hinzuf�gen' should be 'Automatische Antwort hinzufügen')

Looks like funny double or triple encoding. Needs to be investigated.

Originally posted by @bschmalhofer in #1054 (comment)

@bschmalhofer bschmalhofer added this to the OTOBO 10.1 milestone Jul 3, 2021
@bschmalhofer
Copy link
Contributor Author

bschmalhofer commented Jul 8, 2021

Still confused. The PSGI spec says:

The response body MUST be returned from the application as either an array reference or a handle containing the response body as byte strings. The body MUST be encoded into appropriate encodings and MUST NOT contain wide characters (> 255).

But looking inside CGI::Handler::PSGI the content is a string with UTF-Flag on. This looks wrong. Calling utf8::encode($body) before printing the body apparently fixes the encoding issue. So, let's find out whether the body was decoded somewhere or was never encoded. If the body was never encoded, why is it working under Gazelle?

Just a reminder: Use Data::Peek::DDump($var) for showing the flags on a string,

bschmalhofer added a commit that referenced this issue Jul 9, 2021
Honor the PSGI spec. Avoid encoding issues with the wrappers in bin/cgi-bin.
bschmalhofer added a commit that referenced this issue Jul 9, 2021
This gives neater output in case of errors.
@bschmalhofer
Copy link
Contributor Author

bschmalhofer commented Jul 9, 2021

The not encoded body might have been the sole problem. Let's run the test suite:

  • under Docker, using Gazelle
  • locally, using Apache 2.4 and Plack::Handler::PSGI
  • locally, using Apache 2.4 and Modperl::Registry using the wrapper scripts in bin/cgi_bin

@bschmalhofer
Copy link
Contributor Author

Running the test suite under Docker showed one error:

Failed test 'Article displayed using correct encoding'

at /opt/otobo/scripts/test/Selenium/Output/ArticleAttachmentHTMLViewer.t line 236.

Looks like you failed 1 test of 31.

Looks like double encoding of an article from the storage.

bschmalhofer added a commit that referenced this issue Jul 9, 2021
Consequently the param NoEncode is no longer needed.
bschmalhofer added a commit that referenced this issue Jul 10, 2021
Honor the PSGI spec. Avoid encoding issues with the wrappers in bin/cgi-bin.
bschmalhofer added a commit that referenced this issue Jul 10, 2021
This gives neater output in case of errors.
bschmalhofer added a commit that referenced this issue Jul 10, 2021
Consequently the param NoEncode is no longer needed.
bschmalhofer added a commit that referenced this issue Jul 10, 2021
@bschmalhofer
Copy link
Contributor Author

Removed the encoding to UTF-8 in Kernel::Output::HTML::Layout::Attachment(). Thus no double encoding and things look better now.

@bschmalhofer
Copy link
Contributor Author

The remaining test failures do not seem to be related to the encoding. Closing this issue.

bschmalhofer added a commit that referenced this issue Jul 11, 2021
@bschmalhofer bschmalhofer modified the milestones: OTOBO 10.1, OTOBO 10.1.1 Nov 26, 2021
@bschmalhofer
Copy link
Contributor Author

See also #1470.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant