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

iconv problem in containers #2052

Closed
lazyfrosch opened this issue Jan 8, 2020 · 7 comments
Closed

iconv problem in containers #2052

lazyfrosch opened this issue Jan 8, 2020 · 7 comments

Comments

@lazyfrosch
Copy link
Contributor

Expected Behavior

Download should work.

Current Behavior

When downloading an Basket, it fails by showing HTML as text/plain in the browser, listing the exception:

iconv(): Wrong charset, conversion from `UTF-8' to `ISO-8859-11//IGNORE' is not allowed

This code causes it:

$this->getResponse()->setHeader('Content-Disposition', sprintf(
'attachment; filename=Director-Basket_%s_%s.json',
str_replace([' ', '"'], ['_', '_'], iconv(
'UTF-8',
'ISO-8859-11//IGNORE',
$basket->get('basket_name')
)),
substr($snapSum, 0, 7)
));

I'm not sure why we are casting to ISO-8859-1 here, but it seems to fail on some platforms.

Steps to Reproduce (for bugs)

For now I use php on Alpine in lazyfrosch/icingaweb2

Your Environment

  • Director version (System - About): 1.7.2
  • Icinga Web 2 version and modules (System - About): 2.7.3
  • Operating System and version: Alpine Linux 3.10
  • Webserver, PHP versions: 7.3 with FPM under nginx
@lazyfrosch
Copy link
Contributor Author

The magic of multiple implementations... Do we really need these cast?

@Thomas-Gelf
Copy link
Contributor

ISO-8859-11 is a typo, this should read ISO-8859-1. But this shouldn't really matter and not be related to your issue. As far as I can remember, casting takes place as some browsers have issues with UTF-8. Problem is that RFC 2183 required only US-ASCII, and not all browsers understand encodings as of RFC5987. Please don't ask which versions might be affected, some googling shows that at least Safari used to be.

@Thomas-Gelf
Copy link
Contributor

This is currently the only direct use of iconv, and it might be replaced with another piece of "ignore special characters"-code.

Currently there is at least one more use of iconv with //IGNORE in the pipeline. The communication with the Director Daemon Control Socket uses JSON-RPC. This will be an essential component for many upcoming features, as we'll delegate more and more caching/rendering-logic to the daemon. JSON is strict about UTF8, that's why unsafe messages travel through iconv('UTF-8', 'UTF-8//IGNORE', $message). The new JsonRpcLogWriter does so, as it might forward exceptions with unknown / third party or even partially binary messages.

So while replacing this single iconv() might help in the short run, I do not see not using iconv at all being a viable option.

Thomas-Gelf added a commit that referenced this issue Jan 9, 2020
@lazyfrosch
Copy link
Contributor Author

Of course not the problem of Director, just want to make sure if we really need the iconv statement here.

@Thomas-Gelf
Copy link
Contributor

@lazyfrosch: did you dig deeper into this issue? As far as I understood, this happens because of PHP binaries compiled in a "rough" way. Is that assumption true? Any idea of how to detect this issue via PHP application code? It doesn't feel good to know that there might be installations with half-broken iconv out there. Director should warn everybody running it in such an environment.

Additional input on this issue would be highly appreciated!

@Thomas-Gelf Thomas-Gelf reopened this Jan 9, 2020
@lazyfrosch
Copy link
Contributor Author

The problem seems to be that iconv in musl is not implemented to support that conversion, when using GNU iconv it works.

This change helps my problem:
lazyfrosch/docker-icingaweb2@353c5d0

I don't need any further investigation.

macbre added a commit to elecena/python-php that referenced this issue Apr 30, 2020
iconv(): Wrong charset, conversion from `utf-8' to `utf-8//IGNORE' is not allowed

Fixes #8

See Icinga/icingaweb2-module-director#2052
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

2 participants