Re: [modwsgi] Q: Double-encoded environment variables?

2022-08-17 Thread Graham Dumpleton
Can you provide a simple WSGI hello world with some Python code showing how you 
are checking this and what mechanism you are display it if you are?

If you are looking at the Apache error logs to deduce this it can be confusing 
because Apache does it's own encoding on values it gets and so what you see in 
the logs isn't actually what the value may be.

> On 18 Aug 2022, at 1:38 am, 'Albrecht Dreß' via modwsgi 
>  wrote:
> 
> Hi all,
> 
> I ran into a strange issue regarding the encoding of the environment being 
> passed to the Python3 script via
> 
>   def application(env, startResponse): […]
> 
> as it appears to be utf-8 encoded /twice/.  For testing, I added
> 
>   SetEnv X-Test ä
> 
> to the Apache config.  When I call a “traditional” Python3 CGI script, the 
> value of os.environ['X-Test'] contains the UTF-8 encoded value as expected 
> (i.e. the bytes 0xc3 0xa4).
> 
> However, in the script called via modwsgi
> 
>   WSGIScriptAlias /test /path/to/my/script.py
> 
> the value env['X-Test'] contains the bytes 0xc3 0x83 0xc2 0xa4, which is 
> actually the value being regarded as ISO8859-1 (or similar), and then encoded 
> to UTF-8 again.
> 
> My system:
> * Debian Bullseye 64-Bit
> * apache2 v. 2.4.54-1~deb11u1 (standard Debian package)
> * libapache2-mod-wsgi-py3 v. 4.7.1-3 (standard Debian package)
> * python3 v. 3.9.2-3 (standard Debian package)
> 
> I am pretty sure I just missed a crucial configuration setting, but I could 
> not find which one…  Thus, any help to solve this issue would be highly 
> appreciated!
> 
> Thanks in advance,
> Albrecht.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to modwsgi+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/modwsgi/2HM57NL5.5HNUHOW5.K3BMCLQD%40PTUKMMCY.UOWZU43L.FHHJJQFX.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to modwsgi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/5D71561C-6000-425B-8E66-BDB808EED347%40gmail.com.


[modwsgi] Q: Double-encoded environment variables?

2022-08-17 Thread 'Albrecht Dreß' via modwsgi

Hi all,

I ran into a strange issue regarding the encoding of the environment being 
passed to the Python3 script via

def application(env, startResponse): […]

as it appears to be utf-8 encoded /twice/.  For testing, I added

SetEnv X-Test ä

to the Apache config.  When I call a “traditional” Python3 CGI script, the 
value of os.environ['X-Test'] contains the UTF-8 encoded value as expected 
(i.e. the bytes 0xc3 0xa4).

However, in the script called via modwsgi

WSGIScriptAlias /test /path/to/my/script.py

the value env['X-Test'] contains the bytes 0xc3 0x83 0xc2 0xa4, which is 
actually the value being regarded as ISO8859-1 (or similar), and then encoded 
to UTF-8 again.

My system:
* Debian Bullseye 64-Bit
* apache2 v. 2.4.54-1~deb11u1 (standard Debian package)
* libapache2-mod-wsgi-py3 v. 4.7.1-3 (standard Debian package)
* python3 v. 3.9.2-3 (standard Debian package)

I am pretty sure I just missed a crucial configuration setting, but I could not 
find which one…  Thus, any help to solve this issue would be highly appreciated!

Thanks in advance,
Albrecht.

--
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to modwsgi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/2HM57NL5.5HNUHOW5.K3BMCLQD%40PTUKMMCY.UOWZU43L.FHHJJQFX.


pgpfnibMxfw6p.pgp
Description: PGP signature